gfortran找不到那里的图书馆 [英] gfortran can't find library that IS there
问题描述
我无法将我的程序链接到一个库。我从来没有这样做过,所以我可能做一些愚蠢的事情,但据我所知,我做的是正确的事情。我需要将我的程序 foo.f90
链接到位于我家下方目录中的库 libbar.a
目录。我输入命令:
gfortran -c foo.f90
gfortran -o foo foo.f90 -L / directory / of / library -llibbar.a
但是这会引发:
ld:找不到-llibhealpix.a的库b $ b
当然 libhealpix.a
是真正的库(而不是 libbar.a
)
关于为什么会发生这种情况的任何想法? 试试 -lbar
(或者可能 -lhealpix
,如果这是真正的库名)。
-lxyz
会导致搜索名为 libxyz.a
的文件。因此,如果指定 -llibbar.a
,那么文件需要命名为 liblibbar.aa
。
您也可以在gfortran命令行中简单指定存档文件的路径和全名: gfortran -o foo foo.f90 / directory / of / library /libbar.a
I'm having trouble linking my program to a library. I've never done this before so I'm probably doing something stupid, but as far as I can tell I'm doing the right thing. I need to link my program foo.f90
to a library libbar.a
which is in a directory elsewhere below my home directory. I enter the command:
gfortran -c foo.f90
gfortran -o foo foo.f90 -L/directory/of/library -llibbar.a
But this throws:
ld: library not found for -llibhealpix.a
Where of course libhealpix.a
is the real library (rather than libbar.a
)
Any ideas as to why this would occur?
Try -lbar
(or perhaps -lhealpix
, if that's the real library name).
-lxyz
results in a search for a file named libxyz.a
. Consequently, if you specify -llibbar.a
then the file needs to be named liblibbar.a.a
.
You could also simply specify the path and full name of the archive file on the gfortran command line: gfortran -o foo foo.f90 /directory/of/library/libbar.a
这篇关于gfortran找不到那里的图书馆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!