Ubuntu Linux Library Path

40,895

Solution 1

Look at /etc/ld.so.conf and the files in the /etc/ld.so.conf.d/ directory -- that's where it is set.

Solution 2

The file paths can be set explicitly when linking using the -L parameter, as well as the environment variable LD_LIBRARY_PATH.

There are also some paths hard-coded into the linker, using the -L param. You can see these with the command:

gcc -Xlinker -v

Solution 3

When linking, you need to specify the -L flag to indicate where the library is located. At runtime, the dynamic linker uses the paths given in "/etc/ld.so.conf", "/etc/ld.so.conf.d/*" and the value of LD_LIBRARY_PATH.

Solution 4

If it's not a standard path (/lib, /usr/lib), you can specify the location with the compiler flag. For g++, it's -L/some/path/lib. If you use autotools, you can just configure with LDFLAGS=-L/some/path/lib if you need a specific path. If configure has been properly designed for the project, it should have a --with-some-library=PATH option, where you can also specify a path for that library only.

Solution 5

"sudo ldconfig" updates the system's cache if you've just installed something new.

Share:
40,895

Related videos on Youtube

Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    How do I determine the Ubuntu Linux Library Path? That is, how does the linker know where to got to grab the object files when linking my program?