1

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?

Peter VARGA
  • 1,012

1 Answers1

4

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?

Stephen Kitt
  • 434,908