Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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:

/usr/local/lib
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu

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?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: libmtp
Description: libmtp is a library for accessing Media Transfer Protocol devices
Version: 1.1.5
Requires: libusb-1.0
Conflicts:
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)

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.