user230480
user230480

Reputation:

Ubuntu Linux Library Path

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?

Upvotes: 18

Views: 45718

Answers (5)

PanCrit
PanCrit

Reputation: 2718

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

Upvotes: 4

Michael Aaron Safyan
Michael Aaron Safyan

Reputation: 95449

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.

Upvotes: 6

Dirk is no longer here
Dirk is no longer here

Reputation: 368181

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

Upvotes: 14

Drew Dormann
Drew Dormann

Reputation: 63704

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

Upvotes: 9

viraptor
viraptor

Reputation: 34145

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.

Upvotes: 6

Related Questions