gfortran can't find library that IS there

若如初见. 提交于 2019-12-06 04:46:59

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/11753591/gfortran-cant-find-library-that-is-there

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!