make
中,收到以下错误消息。
/usr/bin/ld: cannot find -l/home/testuser/issm/trunk//externalpackages/mpich/install/lib/libmpifort.so
我遵循两个通用的解决方案,但是我还没有找到合适的解决方案。
我想知道-l<NameOfLibrary>
,但是就我而言,我得到了-l<AddrOfLibrary>
。
这是正常情况吗?
有一般的解决方案吗?
我将CMake安装在具有卷共享功能的docker容器中。
因此,我可以完成执行./configure.sh
。
但是在make
中,我遇到了这些错误/usr/bin/ld: cannot find -l<xxx>
CXXLD libISSMCore.la
*** Warning: Linking the shared library libISSMCore.la against the
*** static library /home/testuser/issm/trunk//externalpackages/m1qn3/install/libm1qn3.a is not portable!
*** Warning: Linking the shared library libISSMCore.la against the
*** static library /home/testuser/issm/trunk//externalpackages/m1qn3/install/libddot.a is not portable!
/usr/bin/ld: cannot find -l/home/testuser/issm/trunk//externalpackages/mpich/install/lib/libmpifort.so
collect2: error: ld returned 1 exit status
Makefile:4505: recipe for target 'libISSMCore.la' failed
make[3]: *** [libISSMCore.la] Error 1
make[3]: Leaving directory '/home/testuser/issm/trunk/src/c'
Makefile:460: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/testuser/issm/trunk/src'
Makefile:582: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/testuser/issm/trunk'
Makefile:479: recipe for target 'all' failed
make: *** [all] Error 2
user01@opendataserver:/home/testuser/issm/trunk$ ls ./externalpackages/mpich/install/lib/
libfmpich.so libmpicxx.la libmpifort.so libmpi.so.12.1.0
libmpi.a libmpicxx.so libmpifort.so.12 libmpl.so
libmpichcxx.so libmpicxx.so.12 libmpifort.so.12.1.0 libopa.so
libmpichf90.so libmpicxx.so.12.1.0 libmpi.la pkgconfig
libmpich.so libmpifort.a libmpi.so
libmpicxx.a libmpifort.la libmpi.so.12
解决方案1:一般解决方案〜<失败>失败
/usr/bin/ld: cannot find -lpgm
이는 링크 단계에서 libpgm.so.<숫자> 인 라이브러리를 링크시키지 못했다는 말입니다.
1) find / -name libpgm* -print 를 하여 libpgm.so.x 파일이 존재하는지를 파악하고, 없으면 라이브러리가 제대로 설치가 안된 것입니다.
2) 파일이 존재한다면 LD_LIBRARY_PATH 에 해당 디렉토리가 들어가 있지 않기 때문입니다.
bash의 경우 (libpgm.so.x 파일이 /xxx/xxx1/xxx2/ 디렉토리 밑에 존재한다면)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/xxx/xxx1/xxx2/
3) 다시 컴파일 해보길.. 행운을 빕니다.
Nothing will be happen.
完成
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/testuser/issm/trunk/externalpackages/mpich/install/lib/
解决方案2:类似的解决方案〜 FAILED
First, you need to know the naming rule of lxxx:
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find -lltdl
/usr/bin/ld: cannot find -lXtst
lc means libc.so, lltdl means libltdl.so, lXtst means libXts.so.
So, it is lib + lib-name + .so
Once we know the name, we can use locate to find the path of this lxxx.so file.
$ locate libiconv.so
/home/user/anaconda3/lib/libiconv.so # <-- right here
/home/user/anaconda3/lib/libiconv.so.2
/home/user/anaconda3/lib/libiconv.so.2.5.1
/home/user/anaconda3/lib/preloadable_libiconv.so
/home/user/anaconda3/pkgs/libiconv-1.14-0/lib/libiconv.so
/home/user/anaconda3/pkgs/libiconv-1.14-0/lib/libiconv.so.2
/home/user/anaconda3/pkgs/libiconv-1.14-0/lib/libiconv.so.2.5.1
/home/user/anaconda3/pkgs/libiconv-1.14-0/lib/preloadable_libiconv.so
If you cannot find it, you need to install it by yum (I use CentOS). Usually you have this file, but it does not link to right place.
Link it to the right place, usually it is /lib64 or /usr/lib64
$ sudo ln -s /home/user/anaconda3/lib/libiconv.so /usr/lib64/
Done!
ref: https://i-pogo.blogspot.jp/2010/01/usrbinld-cannot-find-lxxx.html
完成
sudo ln -s /home/testuser/issm/trunk/externalpackages/mpich/install/lib/libmpifort.so /usr/lib/
答案 0 :(得分:2)
-l
(小写L)选项用于指定库名称而不是路径。
要添加搜索库的路径,请使用-L
选项。
您也可以将库的完整路径作为输入文件列出,但是没有任何选项。
因此,请使用选项-L/home/testuser/issm/trunk/externalpackages/mpich/install/lib -lmpifort
或者将普通/home/testuser/issm/trunk//externalpackages/mpich/install/lib/libmpifort.so
用作inout文件(在其他目标文件之后)。