0

This is my /etc/ld.so.conf

/usr/local/lib64
/usr/local/lib
include /etc/ld.so.conf.d/*.conf

The directory /etc/ld.so.conf.d/ contains mysql-x86_64.conf which contains only this one line: /usr/lib64/mysql

The /usr/lib64/mysql directory [listed in the .conf file] contains these files:

total 45,961,216
drwxr-xr-x   2 root root      4,096 Apr 11 17:20 ./
drwxr-xr-x 121 root root     81,920 Mar 30 20:01 ../
-rw-r--r--   1 root root 28,951,398 Dec  9 21:40 libmysqlclient.a
lrwxrwxrwx   1 root root         20 Dec  9 21:56 libmysqlclient.so -> libmysqlclient.so.21*
lrwxrwxrwx   1 root root         25 Dec  9 21:56 libmysqlclient.so.21 -> libmysqlclient.so.21.1.19*
-rwxr-xr-x   1 root root 16,869,104 Dec  9 21:40 libmysqlclient.so.21.1.19*
-rw-r--r--   1 root root     44,910 Dec  9 21:36 libmysqlservices.a

Running ldconfig -p | grep mysql returns this:

    libmysqlclient.so.21 (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so.21
    libmysqlclient.so (libc6,x86-64) => /usr/lib64/mysql/libmysqlclient.so

When I try to link a very small MySQL test program I get this error:

/usr/lib64/gcc/x86_64-suse-linux/9/../../../../x86_64-suse-linux/bin/ld: cannot find -lmysqlclient

Adding -L/usr/lib64/mysql to the linker works.

My question:

According to this answer and other documentation found on internet ldd is considering the content of the /etc/ld.so.conf file - why is in my case the content ignored? What am I doing wrong?

  • You shouldn't have to, but does it find the libraries and work if you start a new shell session? – Nasir Riley Apr 11 at 17:02
  • I don't think ldd (or, by extension, ldconfig) are involved at all in build-time linking - see for example ldconfig issue with non-standard lib directory in CentOS – steeldriver Apr 11 at 17:13
  • I think you may be confusing ldd and ld - they are different things, ldd is only used during dynamic loading of shared libraries at runtime, while ld is responsible for library linkage at build-time – steeldriver Apr 11 at 17:26
  • My comment still applies - ld.so.conf is the configuration file for the run-time dynamic linker ldd (well, really for ld-linux.so these days) and in spite of its name AFAIK has no part in how ld locates libraries at build time. – steeldriver Apr 11 at 17:55
3

ld.so.conf is the configuration file for ld.so, the runtime dynamic linker.

ld ignores it, intentionally. It has its own defaults, supplemented by -L. Typically the search path is also determined by the compiler driving it — see gcc -print-search-dirs for GCC.

LD_LIBRARY_PATH also only affects ld.so, not ld.

See also what are the executable ELF files respectively for static linker, dynamic linker, loader and dynamic loader?

| improve this answer | |
  • Thank you for the clarification. Apparently I got somehow confused by the very similar names. I understand now the difference. – Peter VARGA Apr 12 at 3:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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