makefile f90 issues

241 views
Skip to first unread message

Emily Kelting

unread,
Jul 27, 2021, 11:35:58 AM7/27/21
to Cantera Users' Group
Hello,

I am attempting to run the demo.f90 file on Ubuntu. I am new to Cantera, Fortran, and Linux and running into some issues with compiling. I'm currently getting the following error:

gfortran -g -O3 -Wall -Wextra -std=f2008 -o demo.o -c demo.f90 /usr/include/cantera demo.f90:12:6: 12 | use cantera | 1 Fatal Error: Cannot open module file ‘cantera.mod’ for reading at (1): No such file or directory compilation terminated. make: *** [Makefile:28: demo.o] Error 1

This is my Makefile:

include /usr/include/cantera/Cantera.mak

FC = gfortran
RM = rm -f
FFLAGS = -g -O3 -Wall -Wextra -std=f2008
FMODDIR = $(CANTERA_FORTRAN_MODS)
LDFLAGS = 
LDLIBS = $(CANTERA_FORTRAN_LIBS)
#CPPFLAGS = $(CANTERA_INCLUDES) -O3
SRC = demo.f90
OBJ = $(subst .f90, .o, $(SRC))

all: demo

comp : $(OBJ)
$(FC) $(LDFLAGS) -o comp $(OBJ) $(LDLIBS)

%.o: %.f90
$(FC) $(FFLAGS) -o $@ -c $< $(FMODDIR) $(FDFLAGS)

clean:
$(RM) $(OBJ)

dist-clean: clean
$(RM) *~

I am not sure why it cannot find cantera.mod even though it is in the /usr/include/cantera directory. Can someone help me with this?

Thank you,

Emily

Emily Kelting

unread,
Jul 27, 2021, 2:29:42 PM7/27/21
to Cantera Users' Group
Hi,

I realized there was a typo in my %.o - the $(FDFLAGS) should read $(FFLAGS). After that change, I now get the error:

cc demo.o -L/usr/lib -lcantera_fortran -lcantera -lsundials_cvodes -lsundials_ida -lsundials_nvecserial -lsundials_sunlinsollapackdense -lsundials_sunlinsollapackband -llapack -lblas -lpthread -lstdc++ -o demo /usr/bin/ld: /usr/lib/libcantera.a(ChemEquil.os): undefined reference to symbol 'exp@@GLIBC_2.29' /usr/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [<builtin>: demo] Error 1

Can anyone help me with this? 

Thank you,

Emily

Ray Speth

unread,
Aug 7, 2021, 11:39:54 AM8/7/21
to Cantera Users' Group

Hi Emily,

It looks like you might need to add -lm to the linker command. Adding that to the LDLIBS variable should be sufficient.

Regards,
Ray

Reply all
Reply to author
Forward
0 new messages