0

When I wish to compile a program in Linux from source for which there is no package, there are often libs that need to be installed with a higher version than available through the standard repositories. Rather than using outside repositories, I prefer to compile those updated libraries from source.

How do I configure->make->sudo make install the extra needed libraries and final program so that all the updated libraries and the new program get installed in a separate folder in my home directory and so that ONLY the new program uses those libraries?

Drew
  • 29,895
  • 7
  • 74
  • 104

1 Answers1

0

First compile the library with:

./configure --prefix=$HOME/myapp
make
make install

Note that no "sudo" is needed since you are installing to your own home directory.

Now you need to set up the compilation of the application so that it will find the just installed library. If the application you are going to compile also is using automake, have a look at the help:

./configure --help

Look for something like an option to point out the path to the library.

If you find no way to point out the path to the library, set the CPATH environment variable to point to the include directory of the library and LIBRARY_PATH to point to the subdirectory where the lib-files are located. Something like:

export CPATH=$HOME/myapp/include
export LIBRARY_PATH=$HOME/myapp/lib

If you get everything compiled/installed you have done the hard part. Now, if it's a dynamic executable, you only have to tell the dynamic linker where to find the lib-files. Do this by setting the LD_LIBRARY_PATH environment variable to the same directory pointed out by the LIBRARY_PATH environment variable.

export LD_LIBRARY_PATH=$HOME/myapp/lib

Have a look at the gcc manual page for more information about the CPATH and LIBRARY_PATH environment variables. For information about the LD_LIBRARY_PATH environment variable, look at the ld.so manual page.

Tobias
  • 1