1

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 -l

I 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

Question in ISSM forum

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/

Ref

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/

Ref

jww
  • 97,681
  • 90
  • 411
  • 885
  • What do you mean by "-l"? Nothing you're trying to use is the *address* of anything. – Keith Thompson Oct 17 '19 at 02:19
  • **Cause of -l\< addr of library \>** It is generated from just my **human error** with *incorrect spacing* in configuration option in `... -l mpicxx ...` Thanks to @some-programmer-dude and @Keith-Thompsion – Young Jin Kim Oct 18 '19 at 01:02
  • My point is that "/home/testuser/issm/trunk//externalpackages/mpich/install/lib/libmpifort.so" is not an address. – Keith Thompson Oct 18 '19 at 07:01

1 Answers1

2

The -l (lower-case L) option is to specify a library name not a path.

To add a path to search for libraries use the -L option.

You can also list the full path of the library as an input file, but then without any options.

So either use the options -L/home/testuser/issm/trunk/externalpackages/mpich/install/lib -lmpifort

Or use plain /home/testuser/issm/trunk//externalpackages/mpich/install/lib/libmpifort.so as an inout file (after the other object files).

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • I configure with this option --with-mpi-libflags="-L$ISSM_DIR/externalpackages/mpich/install/lib -lmpi -l mpicxx -lmpifort" \ Is not correct? – Young Jin Kim Oct 17 '19 at 02:07
  • ## Cause of -l\< addr of library \> It is generated from just my **human error** with *incorrect spacing* in configuration option in `... -l mpicxx ...` Thanks to @some-programmer-dude and @Keith-Thompsion – Young Jin Kim Oct 18 '19 at 01:02