Keep these platform-specific considerations in mind for building Connector/C++ applications:
On Windows, applications can be built in different modes (also
called build configurations), which determine the type of the
runtime library that is used by the final executable. An
application can be built in debug or release mode. Then it can
be built in 32-bit or 64-bit mode. Also, one can choose between
the static (
/MT) or the dynamic
/MD) runtime. Different versions of the MSVC
compiler also use different versions of the runtime.
It is important to ensure that the compiler version and the build mode of an application match the same parameters used when building the connector library, to ensure that the connector and the application use the same runtime library.
The binary distribution of Connector/C++ 8.0 ships libraries built in
release mode using dynamic runtime (
libraries are built with MSVC 2015 (the exact compiler version
can be found in the
included in the package). Consequently, the code that uses these
libraries must be built with the same version of MSVC and in
/MD mode. To build code in a different mode,
first build Connector/C++ from source in that mode (see
Section 4.3, “Installing Connector/C++ from Source”), then
build your applications using the same mode.
When linking dynamically, it is possible to build your code in debug mode even if the connector libraries are built in release mode. However, in that case, it will not be possible to step inside connector code during a debug session. To be able to do that, or to build in debug mode while linking statically to the connector, you must build Connector/C++ in debug mode first.
There are separate 64-bit and 32-bit packages, each keeping
libraries in the
lib directories, respectively. Package and
library names also include
vs value in
these names depends on the MSVC compiler version used to build
the libraries (for example,
vs14 for MSVC
2015). This convention enables using libraries built with
different versions of MSVC on the same system.
A dynamic connector library name has a
extension and is used with a import library that has a
.lib extension in the
subdirectory. Thus, a connector dynamic library named
mysqlcppconn8-1-vs14.dll is used with the
import library named
vs14/mysqlcppconn8.lib. The 1 in the
dynamic library name is the major ABI version number. (In the
future, this will help using compatibility libraries with old
ABI together with new libraries having a different ABI.) The
vs14 subdirectory also contains a static
version of the library named
A legacy JDBC connector dynamic library named
mysqlcppconn-7-vs14.dll is used with the
import library named
The corresponding static library is named
When building code that uses Connector/C++ libraries:
$MYSQL_CPPCONN_DIR/includeas an additional include directory and
$MYSQL_CONCPP_DIR/lib64/vs14(64-bit libraries) or
$MYSQL_CONCPP_DIR/lib/vs14(32-bit libraries) as an additional library directory in the project configuration.
To use the dynamic library, add
mysqlcppconn8.libto the linker options (or
mysqlcppconn.libfor legacy code).
For use the static library, add
mysqlcppconn-static.libfor legacy code).
If linking statically, the linker must find the link libraries
.lib extension) for the required
OpenSSL libraries. If the connector was installed from the
binary package provided by Oracle, they are present in the
$MYSQL_CONCPP_DIR/lib/vs14 directory, and the
.dll libraries are
present in the main library directory, next to the connector
A Windows application that uses the connector dynamic library must be able to locate it at runtime, as well as its dependencies such as OpenSSL. The common way of arranging this is to put the required DLLs in the same location as the executable.
The binary distribution of Connector/C++ for macOS is compiled using the macOS native clang compiler. For that reason, an application that uses Connector/C++ should be built with the same clang compiler.
The clang compiler can use two different
implementations of the C++ runtime library: either the native
libc++ or the GNU
libstdc++ library. It is important that an
application uses the same runtime implementation as Connector/C++ that
is, the native
libc++. To ensure that, the
-stdlib=libc++ option should be passed to the
compiler and the linker invocations.
To build a Connector/C++ application that uses X DevAPI, has
app.cc, and links dynamically to
the connector library, the
building on macOS might look like this:
MYSQL_CONCPP_DIR= Connector/C++ installation location CPPFLAGS = -I $(MYSQL_CONCPP_DIR)/include -L $(MYSQL_CONCPP_DIR)/lib64 LDLIBS = -lmysqlcppconn8 CXX = clang++ -stdlib=libc++ CXXFLAGS = -std=c++11 app : app.cc
Binary packages for macOS include OpenSSL libraries that are required by code linked with the connector. These libraries are installed in the same location as the connector libraries and should be found there by the dynamic linker.
As of Connector/C++ 8.0.13, it is possible to build Connector/C++ applications on Solaris. This requires the SunPro 5.15 or higher compiler (from Developer Studio 12.6). Earlier versions and building with GCC are not supported.
To use the Connector/C++ provided by Oracle, application code must be
built with SunPro 5.15 or higher under the following options:
-m64 -std=c++11. The C++ runtime libraries
and atomics library used should be the defaults
The connector library and any code that uses it depends on the GCC runtime libraries shipped with Oracle Developer Studio 12.6, which must be installed before you run the application. See the download options for Oracle Developer Studio here. The installation package enables you to install the runtime libraries only instead of the full Oracle Developer Studio; see instructions in Installing Only the Runtime Libraries on Oracle Solaris 11.