Undefined-reference errors might occur at runtime when you try
to execute a MySQL program. If these errors specify symbols that
mysql_ or indicate that the
libmysqlclient library cannot be found, it
means that your system cannot find the shared
libmysqlclient.so library. The solution to
this problem is to tell your system to search for shared
libraries in the directory where that library is located. Use
whichever of the following methods is appropriate for your
Add the path of the directory where
libmysqlclient.so is located to the
LD_LIBRARY environment variable.
On Mac OS X, add the path of the directory where
libmysqlclient.dylib is located to the
DYLD_LIBRARY_PATH environment variable.
Copy the shared-library files (such as
libmysqlclient.so) to some directory
that is searched by your system, such as
/lib, and update the shared library
information by executing
sure to copy all related files. A shared library might exist
under several names, using symlinks to provide the alternate
Another way to solve this problem is by linking your program
statically with the
-static option, or by
removing the dynamic MySQL libraries before linking your code.
Before trying the second method, you should be sure that no
other programs are using the dynamic libraries.