views:

189

answers:

2

I am linking an application with mysqlclient library on 64-bit CentOS 5.4 and get a linkage error (cannot find -lmysqlclient). The library is in /usr/lib64/mysql/:

una@localhost$ ll /usr/lib64/mysql/
total 9072
    ...
lrwxrwxrwx 1 root root      26 Jan  3 15:54 libmysqlclient_r.so -> libmysqlclient_r.so.15.0.0
lrwxrwxrwx 1 root root      26 Jan  3 15:54 libmysqlclient_r.so.15 -> libmysqlclient_r.so.15.0.0
-rwxr-xr-x 1 root root 1518456 Sep  4 01:28 libmysqlclient_r.so.15.0.0
lrwxrwxrwx 1 root root      24 Jan  3 15:54 libmysqlclient.so -> libmysqlclient.so.15.0.0
lrwxrwxrwx 1 root root      24 Jan  3 15:54 libmysqlclient.so.15 -> libmysqlclient.so.15.0.0
-rwxr-xr-x 1 root root 1514000 Sep  4 01:28 libmysqlclient.so.15.0.0
     ...

And the directory seems to be properly registered for Linux linker:

una@localhost$ cat /etc/ld.so.conf.d/mysql-x86_64.conf 
/usr/lib64/mysql

The only way I can link the application on this machine is by specifying the full path to the library file which is unacceptable in my case. What could cause the problem here?

Thanks.

+2  A: 
-L/usr/lib64/mysql

The ld.so.conf stuff is only used at runtime, not compile time.

Ignacio Vazquez-Abrams
Aha! I forgot ld.so is a loader and has nothing to do with linkage. Thanks.
Jack
+1  A: 

/usr/lib64/mysql is certainly not in your gcc's default search path. You may use a autoconf script to search for the installation path of libmysqlclient on this kind of a distribution, and dynamically use the found location with the -L flag.

Sudhanshu