Let's say we have freetype library already installed in /usr/lib64/libfreetype.so whose version is 1.4 and there is another version of this library that we have compiled and installed in /usr/local/lib/libfreetype.so. How does the build system (make) know which version to use when we are build a software that requires freetype?

2 Answers 2


TL;DR version: it depends.

  • OS: there may be an OS specific environment (LD_LIBRARY_PATH) configuration file or command (such as ldconfig(8)) that registers the paths used to search for libraries.
  • build system: there may be environment variables such as LDFLAGS or command line flags or configuration file settings; mutt has --with-curses=[dir] for when the system (or user) has ncurses under a custom path. These depend on the build system (or even then flavor of make) and may need to be manually written into the autoconf or cmake files.
  • post build configuration: tools such as patchelf (if available) allow different libraries to be selected or the search path altered.
  • 1
    ldconfig is from the 1980s and was withdrawn with the conversion to ELF. LD_LIBRARY_PATH does not control the search for version numbers but rather to directories. So in case that(as usual) the different releases are in the same directory, this does not help.
    – schily
    May 31, 2018 at 14:14
  • 1
    if ldconfig was withdrawn then why did I need to fiddle around with ldconfig on RedHat Enterprise Linux 7 to get NVIDIA/CUDA/tensorflow software compiled?
    – thrig
    May 31, 2018 at 14:49
  • 1
    Well, Linux did take the SunOS-4.0 sources for the dynamic linker from the FreeBSD people and did never upgrade to the recent ELF based version that appeared in 1989 with SVr4.
    – schily
    May 31, 2018 at 14:53

libxxx.so usually is a symbolic link to the shared library file that includes the version in the name.

If you link using -lxxx, then this libxxx.so file is used.

If you like to link against another version, you need to specify the full path name of the library.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .