5.2.2 macOS Notes

This section describes macOS-specific aspects of building Connector/C++ applications. For general application-building information, see Section 5.1, “Building Connector/C++ Applications: General Considerations”.

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 sources in app.cc, and links dynamically to the connector library, the Makefile for building on macOS might look like this:

MYSQL_CONCPP_DIR = Connector/C++ installation location
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.