2

I am trying to install Postfix with MySQL support. When I start or run the postfix daemon, it complains that it "cannot find libmysqlclient.so.18", which is in the directory /usr/local/mysql/lib, which I linked when I built the package.

I added a symlink to /usr/local/mysql/lib/libmysqlclient.so.18 in /usr/lib, which fixed the problem, but that's a really kludgy solution and I'd rather do it the right way.

I followed this documentation, and it works except for that small error.

I am running Arch Linux, kernel version 2.6.33

Caleb
  • 70,105
SirTasty
  • 903

2 Answers2

3

The easiest solution would be to install MySQL from its Arch Linux package, and then the library would be in /usr/lib and everything would work smoothly.

If you're installing MySQL outside the packaging system, then /usr/local/lib is the expected location for libraries; put a symbolic link there. I recommend using stow or xstow to automatically create symbolic links when installing programs from source; see Keeping track of programs.

If you want all programs to look for libraries in /usr/local/mysql/lib, add it to the default library search path in /etc/ld.so.conf. But I rather recommend a symbolic link in /usr/local/lib, if that's what you want.

If you only want Postfix to look for libraries in /usr/local/mysql/lib, edit the script that launches Postfix — something like /etc/rc.d/postfix (I don't know the exact location on Arch). Before the postfix daemon is started, add the line

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH${LD_LIBRARY_PATH:+:}/usr/local/mysql/lib"
  • Installing MySQL with pacman makes sense. Unfortunately, pacman is broken.

    Placing a symlink in usr/local/lib (instead of /usr/lib like I did) would be good. I was just wondering why this was something the user has to do; that's something that could be automated fairly easily. Perhaps it's an oversight?

    – SirTasty Aug 14 '11 at 07:42
0

On Arch Linux I recently had a similar issue with installing libraries from custom builds. In my case it installed the libraries to /usr/local/lib. Running an application which needed this library resulted in a similar runtime error: can't locate the library. (Wouldn't life be easier on a BSD System? :-D )

The proper solution is to add the new local library directory into the runtime linker path. On Arch Linux, this seems to be:

/etc/ld.so.conf

So to add your new library path,

sudo vi /etc/ld.so.conf

then append the path on a new line:

/usr/local/mysql/lib/

In my case, my /etc/ld.conf.so file now looks like the below, because I added /usr/local/lib:

#
# /etc/ld.so.conf
#

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

# End of file

Verify this is correct my using:

sudo ldconfig -v

Your custom libraries should be listed, i.e. they are "found" by the linker.

To get more info on this configuration file and the runtime linker,

man ldconfig

It seems Arch Linux is set up to use a custom directory with multiple config files (/etc/ld.so.conf.d/*.conf) however that's too much SYSV for me and is complete overkill; just add the new paths to /etc/ld.so.conf.