I am using pkg-config to help supply the correct libs during c++ compilation. As I understand it, it searches in directories supplied by /etc/ld.so.conf. My ld.so.conf references the following lib locations via an include directive pointing to /etc/ld.so.conf.d/*.conf:


Problem is the library I need is under /usr/lib by default.

Can I just add in this path to /etc/ld.so.conf myself or move the library or what is the recommended practice?

2 Answers 2


For clarification regarding /etc/ld.so.conf: this file is used by the dynamic (run-time) linker/loader (ld-linux.so on Linux), which resolves symbols in a binary that is loaded to be run (this includes shared libraries as well). This is in contrast with the linker ld, which is used to assemble several object/archive files together and resolves their dependencies.

The dynamic linker checks /etc/ld.so.conf for a list directories in which it should look for shared libraries when loading a binary. Apart from the paths mentioned there, the linker also searches its default paths (/lib and /usr/lib on Linux, usually changed to lib64 for 64-bit loader) unless the binary was linked with a flag that explicitly disables this (-x nodefaultlib in binutils' ld), in which case it only honours ld.so.conf.


pkg-config doesn't use ld.so.conf at all, it normally stores config files in /usr/lib/pkgconfig/, (specify PKG_CONFIG variable if needed)

i.e /usr/lib/pkgconfig/libmtp.pc

# libmtp pkg-config source file


Name: libmtp
Description: libmtp is a library for accessing Media Transfer Protocol devices
Version: 1.1.5
Requires: libusb-1.0
Libs: -L${libdir} -lmtp
Libs.private: -lgcrypt 
Cflags: -I${includedir} 

You can find cflags, libs etc. there, that's how pkg-config supply needed command parameters.

So, for your own lib, create a similar file (read the doc here)

You must log in to answer this question.

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