Oracle 5.0 Reference Manual page 2153

Table of Contents

Advertisement

• The client application should link the C runtime statically by using the
If the client application is built in in debug mode and uses the static debug C runtime
option), it can link to the
If the client application uses the dynamic C runtime
must must be linked to the
The MSDN page describing the link options can be found here:
library/2kzt1wy3.aspx
Troubleshooting Problems Linking to the MySQL Client Library
Linking with the single-threaded library (libmysqlclient) may lead to linker errors related
to
pthread
MYSQL_CLIENT_NO_THREADS
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).
If the linker cannot find the MySQL client library, you might get undefined-reference errors for symbols
that start with mysql_, such as those shown here:
/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+0x69): undefined reference to `mysql_error'
/tmp/ccFKsdPa.o(.text+0x9a): undefined reference to `mysql_close'
You should be able to solve this problem by adding
link command, where
located. To determine the correct directory, try this command:
shell>
mysql_config --libs
The output from
command as well. You can include
using backticks. For example:
shell>
gcc -o progname progname.o `mysql_config --libs`
If an error occurs at link time that the
to the end of the compile/link line.
If you get
undefined reference
end of your link command and try again.
Similarly, if you get undefined-reference errors for other functions that should exist on your system,
such as connect(), check the manual page for the function in question to determine which libraries
you should add to the link command.
If you get undefined-reference errors such as the following for functions that don't exist on your system,
it usually means that your MySQL client library was compiled on a system that is not 100% compatible
with yours:
mf_format.o(.text+0x201): undefined reference to `__lxstat'
In this case, you should download the latest MySQL or MySQL Connector/C source distribution and
compile the MySQL client library yourself. See
Section 20.4, "MySQL
20.6.3.2. Writing C API Threaded Client Programs
Building and Running C API Client Programs
mysqlclient.lib
libmysql.dll
symbols. When using the single-threaded library, please compile your client with
defined. This can be done on the command line by using the
represents the path name of the directory where the client library is
dir_path
might indicate other libraries that should be specified on the link
mysql_config
mysql_config
Connector/C".
static library if that library was built using the same option.
(/MD
option, or
dynamic library. It cannot link to the static client library.
-Ldir_path -lmysqlclient
output directly in your compile or link command
symbol is undefined, link to the math library by adding
floor
errors for the
uncompress
Section 2.17, "Installing MySQL from
2133
compiler option.
/MT
(/MTd
option in debug mode), it
/MDd
http://msdn.microsoft.com/en-us/
at the end of your
or
function, add
compress
Source", and
compiler
option
-D
-lm
to the
-lz

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents