Compiling GnuPG links gpg2 to /lib instead of /usr/local/lib/ [closed]

Occasionally I have to install new packages on servers. If I’m lucky, I can find an RPM, otherwise, I get to bang my head on the wall and attempt to compile a package.

This time I get to compile GnuPG to get version 2.1.15. So I download all the dependent libraries, run configure && make install, lastly I repeat for the gnupg-2.1.15 package itself, and all goes well, and make puts everything in /usr/local/ including libraries and binaries. Feeling lucky, I check the version:

$ /usr/local/bin/gpg2 --version
gpg: Fatal: libgcrypt is too old (need 1.7.0, have 1.6.6)

Oops. What happened, so I check the linked libraries:

$ ldd /usr/local/bin/gpg2
linux-vdso.so.1 (0x00007fff15db4000)
libgcrypt.so.20 => /lib64/libgcrypt.so.20 (0x00007fcab5431000)
libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007fcab521d000)
libassuan.so.0 => /lib64/libassuan.so.0 (0x00007fcab5009000)
libc.so.6 => /lib64/libc.so.6 (0x00007fcab4c47000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fcab4a43000)
/lib64/ld-linux-x86-64.so.2 (0x00005615f5c77000)

Ugh, the old built-in-system libraries have been linked. I don’t compile software much, so I’m stuck here trying to figure out how to tell gcc via configure (or other?) to link the dependent libraries which were just installed in /usr/local/lib/

This is my configure command for gnupg-2.1.15:

./configure --prefix=/usr/local --with-libgpg-error-prefix=/usr/local/\
--with-libgcrypt-prefix=/usr/local --with-libassuan-prefix=/usr/local\
--with-ksba-prefix=/usr/local --with-npth-prefix=/usr/local

Running this on Fedora 24 with latest updates & kernel installed and gcc 6.2.1.

Thanks for taking the time to consider my issue.

Answer

It seems like you require a specific version of the program with its dependent libraries or you are experimenting with your system.

You can use the environment variable LD_LIBRARY_PATH to modify the search path of linker in order to find your new library and use it instead of the old one. Here is a page to provide more details about it.

You can try export LD_LIBRARY_PATH=/usr/local/path/to/lib/directory before executing your program. To make this permanent, you can modify ldconfig search paths (usually files under /etc/ld.so.conf.d) and then invoke ldconfig to update caches.

Attribution
Source : Link , Question Author : Bob Smith , Answer Author : Khaled

Leave a Comment