Module 在Makefile中包含自制Fortran模块和库时出错

Module 在Makefile中包含自制Fortran模块和库时出错,module,makefile,fortran,libraries,Module,Makefile,Fortran,Libraries,我正在尝试构建一个非常简单的Makefile,它打算使用由Fortran模块构成的自制库(libf904QC.a)。库位于/usr/local/lib64中,而相应的.mod文件位于/usr/local/include/f904QC 这是生成文件 # Makefile NAME=NPManip FFLAGS= -ffpe-trap=overflow -c -O3 LFLAGS= PATH2LIB=/usr/local/lib64/ INCLUDEDIR=/usr/local/include/f

我正在尝试构建一个非常简单的Makefile,它打算使用由Fortran模块构成的自制库(
libf904QC.a
)。库位于
/usr/local/lib64
中,而相应的
.mod
文件位于
/usr/local/include/f904QC

这是生成文件

# Makefile
NAME=NPManip
FFLAGS= -ffpe-trap=overflow -c -O3
LFLAGS= 
PATH2LIB=/usr/local/lib64/
INCLUDEDIR=/usr/local/include/f904QC/
#
LIB=-L$(PATH2LIB) -I$(INCLUDEDIR) -lf904QC.a
OBJS = \
tools_NPManip.o\
NPManip.o
%.o: %.f90
        gfortran $(LIB) $(FFLAGS) $*.f90

NPM:   $(OBJS)
        gfortran $(LFLAGS) $(OBJS) $(LIB) -o $(NAME)

clean:
        @if test -e $$HOME/bin/$(NAME); then \
        rm $$HOME/bin/$(NAME); \
        fi
        rm *.o *.mod

mrproper: clean
        rm $(NAME)

install:
        ln -s $(shell pwd)/$(NAME) $$HOME/bin/.
我收到以下错误消息:

gfortran tools_NPManip.o NPManip.o-L/usr/local/lib64/-I/usr/local/include/f904QC/-lf904QC.a-o NPManip

/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../../../../../x86_64-suse-linux/bin/ld:找不到-lf904QC.a

collect2:错误:ld返回了1个退出状态

制造::[NPM]错误1

错在哪里?这对我来说并不明显,因为
libf904QC.o
实际上位于
/usr/local/lib64
中,由
-L
选项定义


感谢您的帮助

在这种情况下,您应该指定库
/usr/local/lib64/libf904QC.a
的完整路径,或者指定
-L/usr/local/lib64-lf90QC
,而不指定
.a
。从
手册ld

   -l namespec
   --library=namespec
       Add the archive or object file specified by namespec to the list of files to link.  This option may be used any number of
       times.  If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it
       will search the library path for a file called libnamespec.a.

   -L searchdir
   --library-path=searchdir
       Add path searchdir to the list of paths that ld will search for archive libraries and ld control scripts.  You may use
       this option any number of times.  The directories are searched in the order in which they are specified on the command
       line.  Directories specified on the command line are searched before the default directories.  All -L options apply to
       all -l options, regardless of the order in which the options appear.  -L options do not affect how ld searches for a
       linker script unless -T option is specified.

您正在尝试与对象
libf904QC.o
或存档
libf904QC.a
链接吗?尝试用目标文件的完整路径替换
-lf904QC.a
。谢谢!我已经指定了-L/usr/local/lib64-lf90QC,当然它工作得很好。现在看起来很明显,但不是昨天。这就像埃德加·坡被偷的信。解决方案就在你眼前,但你却看不见。。。