MySQL Connector/C Developer Guide

4.2.1 Installing Connector/C from Source on Unix and Unix-Like Systems

If the native compiler toolset for the target platform is available (for example, SunStudio for Solaris), you can use that for compilation. Alternatively, the GNU toolset can be used on all platforms.

You also need CMake 2.6 or newer, which is available from

To build and install the source distribution, use the following procedure:

  1. Change location to the top-level directory of the source distribution.

  2. Generate the Makefile:

    shell> cmake -G "Unix Makefiles"

    Or, for a Debug build:

    shell> cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug

    By default, the installation location for Connector/C is /usr/local/mysql. To change this location, use the CMAKE_INSTALL_PREFIX option to specify a different directory when generating the Makefile. For example:

    shell> cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/opt/local/mysql

    For other CMake options that you might find useful, see Other Connector/C Build Options.

  3. Build the project:

    shell> make
  4. As root, install the Connector/C headers, libraries, and utilities:

    root-shell> make install