Reputation: 795
I have a Fortran file my.f90 which uses some Math libraries. The two flags for the include and library files are defined in a .csh file
INC_FLAG = "-I$MATH_DIR/include/LIB_ARCH"
LINK_FLAG= "-L$MATH_DIR/lib/lib$LIB.ARCH -Bdynamic -limsl -limslblas"
In terminal this works perfectly fine
gfortran -o my.o $INC_FLAG my.f90 $LINK_FLAG
But when I try to do the compilation and linking in Separates steps I can not do it. This fails
gfortran -c $INC_FLAG my.f90
gfortran -o my.o $LINK_FLAG
I need to do the compilation and linking separately because I will have many source files (.f90) and need to make a makefile where compilation and linking are done separately. My makefile does not work either
all: my.o
gfortran -o my.o $(LINK_F90)
my.o: my.f90
gfortran $(F90FLAGS) -c my.f90 $<
clean:
rm my.o
What is going on here?
Upvotes: 1
Views: 359
Reputation: 18098
gfortran -c $INC_FLAG my.f90
will compile the object my.o
. The option -o
specifies the name of the output file - as this is my.o
again (in your case), this has to fail!
Try gfortran -o APPLICATIONNAME my.o $LINK_FLAG
.
The same holds for the Makefile.
Upvotes: 2