Hi all!
For the sake of convenience I'm creating package with AmberTools 
software so it can be easily built everywhere. The problem is that some 
software inside AmberTools package hardcodes libraries inside final 
executables. For example, yesterday I noticed that ambpdb utility can't 
be run because of missing library (even after loading AmberTools 
modulefile which sets up proper LD_LIBRARY_PATH). ldd gives the 
following for this binary:
[viktor.desolve-lab /opt/ambertools/bin]$ ldd ambpdb
     linux-vdso.so.1 (0x00007ffc33795000)
/opt/buildcache/makepkg/ambertools/src/amber18/lib/libcpptraj.so => not 
found
     libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x000014b691895000)
     libm.so.6 => /usr/lib/libm.so.6 (0x000014b69174f000)
     libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x000014b691735000)
     libc.so.6 => /usr/lib/libc.so.6 (0x000014b691570000)
     /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 
(0x000014b691a87000)
need to say: package manager used (makepkg on Arch Linux) performs all 
compiling operations inside its' own temporary directory and then moves 
files in place. So, as you can see, ambpdb is linked against 
full-specified path of libcpptraj.so instead of just libcpptraj.so 
without full path. So when I trying to start ambpdb then I get the 
following error:
[viktor.desolve-lab /tmp]$ ambpdb
ambpdb: error while loading shared libraries: 
/opt/buildcache/makepkg/ambertools/src/amber18/lib/libcpptraj.so: cannot 
open shared object file: No such file or directory
However, LD_LIBRARY_PATH is set up correctly:
[viktor.desolve-lab /tmp]$ echo $LD_LIBRARY_PATH
/opt/ambertools/lib
I digged a bit with source code and found that the problem is related to 
the Makefile of ambpdb. Seems like libcpptraj.so is fed directly to the 
linker with full path like simple object. If I change linking line and 
then manually rebuild ambdpdb submodule then library dependencies are 
working fine:
--- AmberTools/src/ambpdb/Makefile    2019-04-25 15:49:55.000000000 +0300
+++ AmberTools/src/ambpdb/Makefile 2019-05-03 18:13:21.416508507 +0300
.. -26,7 +26,7 ..
  ambpdb: $(AMBPDB_OBJECTS) $(LIBCPPTRAJ)
      .echo "[AMBPDB]  CXX $."
-    $(VB)$(CXX) -o ambpdb$(SFX) $(AMBPDB_OBJECTS) $(LIBCPPTRAJ) $(LDFLAGS)
+    $(VB)$(CXX) -o ambpdb$(SFX) $(AMBPDB_OBJECTS) $(LDFLAGS) 
-L"/home/viktor/build/src/amber18/lib" -lcpptraj
  # Build rules
Now ldd deps looks fine:
[viktor.desolve-lab /tmp]$ ldd ambpdb
     linux-vdso.so.1 (0x00007fff7c5c0000)
     libcpptraj.so => not found
     libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x000014ff46390000)
     libm.so.6 => /usr/lib/libm.so.6 (0x000014ff4624a000)
     libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x000014ff46230000)
     libc.so.6 => /usr/lib/libc.so.6 (0x000014ff4606b000)
     /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 
(0x000014ff46582000)
And when I load AmberTools modulefile I get proper library dependencies 
list:
[viktor.desolve-lab /tmp]$ module load ambertools/19
[viktor.desolve-lab /tmp]$ ldd ambpdb
     linux-vdso.so.1 (0x00007ffff413f000)
     libcpptraj.so => /opt/ambertools/lib/libcpptraj.so (0x0000151f9602f000)
     libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x0000151f95e4a000)
     libm.so.6 => /usr/lib/libm.so.6 (0x0000151f95d04000)
     libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x0000151f95cea000)
     libc.so.6 => /usr/lib/libc.so.6 (0x0000151f95b25000)
     libgfortran.so.5 => /usr/lib/libgfortran.so.5 (0x0000151f958a9000)
     libnetcdf.so.15 => /usr/lib/libnetcdf.so.15 (0x0000151f95757000)
     libbz2.so.1.0 => /usr/lib/libbz2.so.1.0 (0x0000151f95744000)
     libz.so.1 => /usr/lib/libz.so.1 (0x0000151f9552d000)
     /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 
(0x0000151f96799000)
     libquadmath.so.0 => /usr/lib/../lib/libquadmath.so.0 
(0x0000151f954ea000)
     libhdf5_hl.so.100 => /usr/lib/libhdf5_hl.so.100 (0x0000151f954c5000)
     libhdf5.so.103 => /usr/lib/libhdf5.so.103 (0x0000151f95142000)
     libcurl.so.4 => /usr/lib/libcurl.so.4 (0x0000151f950b3000)
     libsz.so.2 => /usr/lib/libsz.so.2 (0x0000151f94eb0000)
     libdl.so.2 => /usr/lib/libdl.so.2 (0x0000151f94eab000)
     libnghttp2.so.14 => /usr/lib/libnghttp2.so.14 (0x0000151f94e83000)
     libidn2.so.0 => /usr/lib/libidn2.so.0 (0x0000151f94e64000)
     libssh2.so.1 => /usr/lib/libssh2.so.1 (0x0000151f94e31000)
     libpsl.so.5 => /usr/lib/libpsl.so.5 (0x0000151f94e1e000)
     libssl.so.1.1 => /usr/lib/libssl.so.1.1 (0x0000151f94d8e000)
     libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x0000151f94aba000)
     libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 
(0x0000151f9486c000)
     libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x0000151f94583000)
     libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x0000151f9434e000)
     libcom_err.so.2 => /usr/lib/libcom_err.so.2 (0x0000151f94348000)
     libpthread.so.0 => /usr/lib/libpthread.so.0 (0x0000151f94327000)
     libaec.so.0 => /usr/lib/libaec.so.0 (0x0000151f9411e000)
     libunistring.so.2 => /usr/lib/libunistring.so.2 (0x0000151f93d9e000)
     libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 
(0x0000151f93b8f000)
     libkeyutils.so.1 => /usr/lib/libkeyutils.so.1 (0x0000151f93b88000)
     libresolv.so.2 => /usr/lib/libresolv.so.2 (0x0000151f93b6f000)
[viktor.desolve-lab /tmp]$ echo $LD_LIBRARY_PATH
/opt/ambertools/lib
Of course, there exists more robust way to link with necessary libraries 
without specifying paths explicitly as I did above in Makefile for 
ambpdb but it was only done for quick-testing purposes.
Also I can say that there are some other programs which hardcodes 
library names inside their binaries - makepkg checks if final package 
files include absolute paths to buildroot environment (in my case 
/opt/buildcache/makepkg) and throws a warning. I can list all cases if 
you need it.
What can we do to workaround that bug? May be we just should wait for an 
official patch? Thank you!
_______________________________________________
AMBER mailing list
AMBER.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber
Received on Sat May 04 2019 - 04:00:02 PDT