Documentation Home
MySQL Connector/C++ 1.1 Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 285.1Kb
PDF (A4) - 286.0Kb


MySQL Connector/C++ 1.1 Developer Guide  /  Installing Connector/C++ from Source  /  Dynamically Linking Connector/C++ Against the MySQL Client Library

4.5 Dynamically Linking Connector/C++ Against the MySQL Client Library

Note

This section refers to dynamic linking of Connector/C++ to the client library, not dynamic linking of applications to Connector/C++. Precompiled binaries of Connector/C++ use static binding with the client library by default.

An application that uses Connector/C++ can be linked either statically or dynamically to the Connector/C++ libraries. Connector/C++ is usually linked statically to the underlying MySQL client library.

It is also possible to link dynamically to the underlying MySQL client library, although this capability is not enabled by default. To link Connector/C++ dynamically to the client library, disable MYSQLCLIENT_STATIC_LINKING when building Connector/C++ from source:

rm CMakeCache.txt
cmake . -DMYSQLCLIENT_STATIC_LINKING=0
make clean
make
make install

Now, when creating a connection in your application, Connector/C++ selects and loads a client library at runtime. It chooses the client library by searching defined locations and environment variables depending on the host operating system. It is also possible when creating a connection in an application to define an absolute path to the client library to load at runtime. This can be convenient if you have defined a standard location from which you want the client library to be loaded. This is sometimes done to circumvent possible conflicts with other versions of the client library that may be located on the system.

If MYSQLCLIENT_STATIC_LINKING is disabled to enable dynamic linking to the MySQL client library, MYSQLCLIENT_STATIC_BINDING determines whether to link to the shared MySQL client library. By default, MYSQLCLIENT_STATIC_BINDING is enabled. If MYSQLCLIENT_STATIC_BINDING is disabled, Connector/C++ is not linked to the shared MySQL client library. Instead, that library is loaded and mapped at runtime.