environment
- ubuntu 18.04
- I want to install ISSM (ice sheet system model)
- In this process, it needs to install many external packages.
- In the
make
, I got the following error message./usr/bin/ld: cannot find -l/home/testuser/issm/trunk//externalpackages/mpich/install/lib/libmpifort.so
I follow two(?) general solutions, but I don't yet find a fittable solution.
I wonder -l<NameOfLibrary>
, but, in my case, I got -l<AddrOfLibrary>
.
Is this a normal case?
Is there a general solution?
My original question:
/usr/bin/ld: cannot find ld -lI install CMake in a docker container with volume sharing.
So, I can finish to execute ./configure.sh
.
But among make
, I got these error /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
Solution1: general solution ~ FAILED
/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.
Done
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/testuser/issm/trunk/externalpackages/mpich/install/lib/
Solution2: similar solution ~ 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
Done
sudo ln -s /home/testuser/issm/trunk/externalpackages/mpich/install/lib/libmpifort.so /usr/lib/