MySQL Connector/C++ Developer Guide  /  Building Connector/C++ Applications  /  Building Connector/C++ Applications: General Considerations

5.1 Building Connector/C++ Applications: General Considerations

Keeps these considerations in mind for building Connector/C++ applications:

Build Tools and Configuration Settings

It is important that the tools you use to build your Connector/C++ applications are compatible with the tools used to build Connector/C++ itself. Ideally, build your applications with the same tools that were used to build the Connector/C++ binaries.

To avoid issues, ensure that these factors are the same for your applications and Connector/C++ itself:

  • Compiler version.

  • Runtime library.

  • Runtime linker configuration settings.

To avoid potential crashes, the build configuration of Connector/C++ should match the build configuration of the application using it. For example, do not use the release build of Connector/C++ with a debug build of the client application.

To use a different compiler version, release configuration, or runtime library, first build Connector/C++ from source using your desired settings (see Chapter 4, Installing Connector/C++ from Source), then build your applications using those same settings.

Connector/C++ binary distributions include a BUILDINFO.txt file that describes the environment and configuration options used to build the distribution. If you installed Connector/C++ from a binary distribution and experience build-related issues on a platform, it may help to check the settings that were used to build the distribution on that platform.

C++11 Support

X DevAPI uses C++11 language features. For that reason, enable C++11 support in the compiler using the -std=c++11 option when building Connector/C++ applications that use X DevAPI. This option is not needed for applications that use X DevAPI for C (which is a plain C API) or the legacy JDBC API (which is based on plain C++), unless the application code uses C++11.

Boost Header Files

To compile applications that use Connector/C++, the Boost header files are needed if you use the legacy JDBC API. For applications that use X DevAPI or X DevAPI for C, the Boost header files are needed on Unix and Unix-like platforms if you build using gcc and the version of the C++ standard library on your system does not implement the UTF8 converter (codecvt_utf8).

If the Boost header files are needed, Boost 1.59.0 or newer must be installed, and the location of the headers must be added to the include path. To obtain Boost and its installation instructions, visit the official Boost site.

Link Libraries

When Connector/C++ is built using OpenSSL, it makes the connector library dependent on OpenSSL dynamic libraries:

  • When linking an application to Connector/C++ dynamically, this dependency is relevant only at runtime.

  • When linking an application to Connector/C++ statically, the OpenSSL libraries should be linked as well. On Linux, this means adding -lssl -lcrypto explicitly to the compile/link command. On Windows, this is handled automatically.

On Windows, link to the dynamic version of the C++ Runtime Library.

Runtime Libraries

X DevAPI for C applications need libstdc++ at runtime. Depending on your platform or build tools, a different library may apply. For example, the library is libc++ on macOS; see macOS Notes.

If an application is built using dynamic link libraries, those libraries must be present not just on the build host, but on target hosts where the application runs. The libraries and their runtime dependencies must be found by the dynamic linker. The dynamic linker must be properly configured to find Connector/C++ libraries and their dependencies.

Connector/C++ libraries built by Oracle depend on the OpenSSL libraries. The latter must be installed on the system in order to run code that links against Connector/C++ libraries. Another option is to put the OpenSSL libraries in the same location as Connector/C++ In this case the dynamic linker should find them next to the connector library. See also macOS Notes, and Windows Notes.

It is possible to build Connector/C++ with an SSL library other than OpenSSL. Use the WITH_SSL CMake option to specify which SSL library to use (see Section 4.4, “Connector/C++ Source-Configuration Options”). For applications linked against Connector/C++ libraries that are not built using OpenSSL, the OpenSSL libraries are not required at runtime.

On Windows, target hosts running the client application must have the Visual C++ Redistributable for Visual Studio installed. The required version is VC++ Redistributable 2015.


User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
Sign Up Login You must be logged in to post a comment.