MySQL Connector/C Developer Guide  /  ...  /  Installing Connector/C from Source on Microsoft Windows

4.2.2 Installing Connector/C from Source on Microsoft Windows

To build Connector/C on Microsoft Windows, Visual Studio 8 or 9 is recommended. The Express Edition of Visual Studio and other compilers might work, but are untested.

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

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

  1. Set the environment variables for the Visual Studio toolchain. Visual Studio includes a batch file to set these for you, and installs a shortcut in the Start menu to open a command prompt with these variables set.

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

  3. Generate the Makefile by entering the following command in a command-prompt window:

    shell> cmake -G "Visual Studio 9 2008"

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

    The result of the cmake command is a project (solution) file, libmysql.sln, that you can open with Visual Studio. Alternatively, build from the command line with either of these commands:

    shell> libmysql.sln /build Release
    shell> libmysql.sln /build RelWithDebInfo

    For other versions of Visual Studio or for an nmake-based build, use the following command to check which generators can be specified with the -G option:

    shell> cmake --help

    To compile a Debug build, you must set the CMake build type so the correct external library versions are used, then compile using the Debug solution configuration:

    shell> cmake -G "Visual Studio 9 2008" -DCMAKE_BUILD_TYPE=Debug
    shell> libmysql.sln /build Debug

    A normal build builds the C API libraries for the lib directory. A Debug build additionally builds debug libraries for the lib/debug directory. You must use the debug libraries to compile clients built using the debug C runtime.

  4. Use the install operation provided by your development environment to install the Connector/C headers, libraries, and utilities. You can also use this CMake command:

    shell> cmake --build . --target INSTALL --config RelWithDebInfo

User Comments
Sign Up Login You must be logged in to post a comment.