我正在Fortran90中编写代码。我需要使用LAPACK库中的dgesv函数。我有几个子程序,我正在使用make file
与gfortran进行编译。我可以使用
gfortran test.f -L/path/to/libs -llapack -lblas
任何人都可以帮忙如何将这些库添加到我的make文件中吗?我的make文件如下:
.SUFFIXES:
.SUFFIXES: .f .o .f90
#
LIBDIR = lib
UNAME := $(shell uname)
DEFINE =
FCOMP = gfortran
FOPTS = -fdefault-real-8 -g -fbounds-check -fbacktrace -O2 -Wline-truncation
F90OPTS = -ffree-form -ffree-line-length-none
#FOPTS = -fPIC -g
OBJS = read_model_2d_elasto.o output_2d_elasto.o 2d_elastostatics_FEM.o stiffness_2d_elasto.o stress_strain_2d_elasto.o \
XLIBS = -L/usr/X11R6/lib64 -lX11 -lpthread
GLIBS = -L/usr/X11R6/lib64 -lGLU -lGL -lX11 -lXext -lpthread
#default: 2d_elastostatics_FEM techop
all: 2d_elastostatics_FEM
ifeq ($(UNAME),Darwin)
2d_elastostatics_FEM:$(OBJS)
$(FCOMP) -g $(OBJS) -o 2d_elastostatics_FEM
else
2d_elastostatics_FEM:$(OBJS)
$(FCOMP) -g -static $(OBJS) -o 2d_elastostatics_FEM
endif
.f.o:; $(FCOMP) -c -o $@ $(FOPTS) $*.f
.f90.o:; $(FCOMP) -c -o $@ $(FOPTS) $(F90OPTS) $*.f90
clean:
-rm -f 2d_elastostatics_FEM $(OBJS) *.mod *.x *.exe
答案 0 :(得分:1)
在Makefile
中使用用于XLIBS和GLIBS的sme方式BLIBS = -L/path/to/libs -llapack -lblas
...
ifeq ($(UNAME),Darwin)
2d_elastostatics_FEM:$(OBJS)
$(FCOMP) -g $(OBJS) -o 2d_elastostatics_FEM $(BLIBS)
else
2d_elastostatics_FEM:$(OBJS)
$(FCOMP) -g -static $(OBJS) -o 2d_elastostatics_FEM $(BLIBS)
endif