When linking with the C API, the following errors may occur on some systems:
gcc -g -o client test.o -L/usr/local/lib/mysql \ -lmysqlclient -lsocket -lnsl Undefined first referenced symbol in file floor /usr/local/lib/mysql/libmysqlclient.a(password.o) ld: fatal: Symbol referencing errors. No output written to client
If this happens on your system, you must include the math
library by adding -lm
to the end of the
compile/link line.
Linking with the single-threaded library
(libmysqlclient
) may lead to linker errors
related to pthread
symbols. When using the
single-threaded library, please compile your client with
MYSQL_CLIENT_NO_THREADS
defined. This can be
done on the command line by using the -D
option
to the compiler, or in your source code before including the
MySQL header files. This define should not be used when building
for use with the thread-safe client library
(libmysqlclient_r
).
User Comments
If you are learning to use the c API and your executable produces an error like "ld.so.1: test: fatal: libmysqlclient.so.12: open failed: No such file or directory"
then you need to set the environment variable $LD_LIBRARY_PATH to read the shared library file. E.g., for csh /tcsh
setenv LD_LIBRARY_PATH /opt/gnu/lib:/export/local/mysql/lib/mysql
Add your own comment.