I often build various libraries from source code to play with, such as gmp-6.1.2, mpfr-4.0.1, and gcc-7.x. In doing so, I prefer to use --prefix=/usr/local/gcc-7.2.0
so I know exactly where it is installed and does not mess up existing libraries. And then I all I basically know is what make install
tells me at the end, to update or set LD_LIBRARY_PATH
and sometimes but not always LD_RUN_PATH
.
most of the time I just manually set LD_LIBRARY_PATH
as needed later on, or set it globally in something like /etc/bash.bashrc.local
and that has worked.
This is what make install
says:
Libraries have been installed in:
/usr/local/mfprtest/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
Is there a better way, or a more offical way? of using ldconfig and ld.so.conf
than using LD_LIBRARY_PATH
and LD_RUN_PATH
, and PATH
? This is specifically for writing my own code, but could be for other users, where I want to link against various newer versions of a library than what's installed with a given linux version, such as gmp, mpfr, and then using various manually installed versions of gcc such as gcc-5.x or gcc-6.x or gcc-7.x.
basically, once I install /usr/local/gcc-7.3.0
for example, I want myself and any other user who either writes or runs home grown c, c++, or fortran source code on the system to use /usr/local/gcc-7.3.0
and not the system versions in /usr/bin/ and /usr/lib64/