Dynamically Linking MariaDB Connector/C++ against the MariaDB Client Library
An application that uses MariaDB Connector/C++ can be either statically or dynamically linked to the MariaDB Connector/C++ libraries. MariaDB Connector/C++ is usually statically linked to the underlying MariaDB Client Library (or Connector/C). Note, that unless otherwise stated, reference to the MariaDB Client Library is also taken to include Connector/C, which is a separately packaged, stand alone version of the MariaDB Client Library. From MariaDB Connector/C++ version 1.1.0 it is possible to also dynamically link to the underlying MariaDB Client Library. The ability of MariaDB Connector/C++ to dynamically link to MariaDB Client Library is not enabled by default, and enabling this feature is done through a compile time option, when compiling the MariaDB Connector/C++ source code.
To use the ability to dynamically link the client library to MariaDB Connector/C++, define the MYSQLCLIENT_STATIC_BINDING:BOOL
when building the MariaDB Connector/C++ source code:
rm CMakeCache.txt cmake -DMYSQLCLIENT_STATIC_BINDING:BOOL=1 . make clean make make install
Note that precompiled binaries of MariaDB Connector/C++ use static binding with the client library by default.
Now, in your application, when creating a connection, MariaDB 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.