Copyright (C) 2000-2012 |
GNU Info (mysql.info)Link errorsProblems When Linking with the MySQL Client Library --------------------------------------------------- If you are linking your program and you get errors for unreferenced symbols that start with `mysql_', like the following: /tmp/ccFKsdPa.o: In function `main': /tmp/ccFKsdPa.o(.text+0xb): undefined reference to `mysql_init' /tmp/ccFKsdPa.o(.text+0x31): undefined reference to `mysql_real_connect' /tmp/ccFKsdPa.o(.text+0x57): undefined reference to `mysql_real_connect' /tmp/ccFKsdPa.o(.text+0x69): undefined reference to `mysql_error' /tmp/ccFKsdPa.o(.text+0x9a): undefined reference to `mysql_close' you should be able to solve this by adding `-Lpath-to-the-mysql-library -lmysqlclient' *LAST* on your link line. If you get `undefined reference' errors for the `uncompress' or `compress' function, add `-lz' *LAST* on your link line and try again! If you get `undefined reference' errors for functions that should exist on your system, like `connect', check the man page for the function in question, for which libraries you should add to the link line! If you get `undefined reference' errors for functions that don't exist on your system, like the following: mf_format.o(.text+0x201): undefined reference to `__lxstat' it usually means that your library is compiled on a system that is not 100 % compatible with yours. In this case you should download the latest MySQL source distribution and compile this yourself. Note: Installing source. If you are trying to run a program and you then get errors for unreferenced symbols that start with `mysql_' or that the `mysqlclient' library can't be found, this means that your system can't find the share `libmysqlclient.so' library. The fix for this is to tell your system to search after shared libraries where the library is located by one of the following methods: * Add the path to the directory where you have `libmysqlclient.so' the `LD_LIBRARY_PATH' environment variable. * Add the path to the directory where you have `libmysqlclient.so' the `LD_LIBRARY' environment variable. * Copy `libmysqlclient.so' to some place that is searched by your system, like `/lib', and update the shared library information by executing `ldconfig'. Another way to solve this problem is to link your program statically, with `-static', or by removing the dynamic MySQL libraries before linking your code. In the second case you should be sure that no other programs are using the dynamic libraries! automatically generated by info2www version 1.2.2.9 |