Overriding default search location for library on Ubuntu 12.04.1

To properly compile the mpfr library on my Ubuntu 12.04.1 system (64-bit), I need to update the C_INCLUDE_PATH, LIBRARY_PATH, LD_LIBRARY_PATH and LD_RUN_PATH variables. This is mentioned in the FAQ for building the mpfr library. Updating these variables is required since the gmp library is already on the search paths and included as a part of the default Ubuntu install. However, I've installed the gmp library in my /usr/local/lib directory.

In my home directory, I've created a .pam_environment file and placed the following lines:

export C_INCLUDE_PATH=/usr/local/include:$C_INCLUDE_PATH
export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export LD_RUN_PATH=/usr/local/lib:$LD_RUN_PATH 

However, the mpfr library configure script still can't find my own version of the gmp library in the /usr/local/lib directory.

Looking inside of the /etc/ld.so.conf.d directory, the contents of my libc.conf file is:

# libc default configuration
/usr/local/lib

Also, the contents of the x86_64-linux-gnu.conf file is:

# Multiarch support
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu

However, running locate libgmp on the command line shows that there is already a version of libgmp that ships with the system.

$ locate libgmp
/usr/lib/x86_64-linux-gnu/libgmp.so.10
/usr/lib/x86_64-linux-gnu/libgmp.so.10.0.2
/usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libgmp.so
/usr/share/doc/libgmp10
/usr/share/doc/libgmp10/README.Debian
/usr/share/doc/libgmp10/TODO.Debian
/usr/share/doc/libgmp10/changelog.Debian.gz
/usr/share/doc/libgmp10/copyright
/var/lib/dpkg/info/libgmp10:amd64.list
/var/lib/dpkg/info/libgmp10:amd64.md5sums
/var/lib/dpkg/info/libgmp10:amd64.postinst
/var/lib/dpkg/info/libgmp10:amd64.postrm
/var/lib/dpkg/info/libgmp10:amd64.shlibs

Questions:

  1. How do I override the location of the libgmp version used during linking? I would like to use the library in the \usr\local\lib directory.
  2. Do I place the C_INCLUDE_PATH and other variables in my .pam_environment file, or is there a more appropriate location?

1 Answer

The simplest solution to this problem appears to be installing the library in another location:

./configure --prefix=/home/usr/local

Then, the library in this directory is selected when linking. Another possibility would be to rename /usr/lib/x86_64-linux-gnu/openssl-1.0.0/engines/libgmp.so to something else, but this is not especially clever if the library is used by a program installed on the system.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like