Spec-Zone .ru
спецификации, руководства, описания, API

22.4.3.3. Dynamically Linking MySQL Connector/C++ Against the MySQL Client Library

Note

This section refers to dynamic linking of MySQL Connector/C++ with the client library, not dynamic linking of the application to MySQL Connector/C++.

Precompiled binaries of MySQL Connector/C++ use static binding with the client library by default.

An application that uses MySQL Connector/C++ can be either statically or dynamically linked to the MySQL Connector/C++ libraries. MySQL Connector/C++ is usually statically linked to the underlying MySQL client library (or Connector/C). Note that, unless otherwise stated, reference to the MySQL client library is also taken to include Connector/C, which is a separately packaged, standalone version of the MySQL client library. From MySQL Connector/C++ 1.1.0 on, it is possible to also dynamically link to the underlying MySQL client library. The ability of MySQL Connector/C++ to dynamically link to MySQL client library is not enabled by default. Enabling this feature is done through a compile-time option when compiling the MySQL Connector/C++ source code.

To use the ability to dynamically link the client library to MySQL Connector/C++, define the MYSQLCLIENT_STATIC_BINDING:BOOL when building the MySQL Connector/C++ source code:

shell> rm
        CMakeCache.txtshell> cmake
        -DMYSQLCLIENT_STATIC_BINDING:BOOL=1 .shell> make cleanshell> makeshell> make
        install

Now, in your application, when creating a connection, MySQL Connector/C++ will select and load a client library at runtime. It will choose 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 be loaded 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.