Spec-Zone .ru
спецификации, руководства, описания, API

22.5.4.2. Installing MySQL Connector/C from Source

A MySQL Connector/C source distribution is packaged as a compressed tar file, Zip archive, or RPM package, denoted here as PACKAGE.tar.gz, PACKAGE.zip, or. PACKAGE.src.rpm. A source distribution in tar file or Zip archive format can be used on any supported platform listed in Section 22.5.2, "MySQL Connector/C Supported Platforms". An RPM package source distribution is intended for RPM-based systems such as Linux.

To install a compressed tar file, use this command in the intended installation directory:

shell> tar zxvf PACKAGE.tar.gz

After unpacking the distribution, build it using the appropriate instructions for your platform later in this section.

To unpack a Zip archive, use WinZip or another tool that can read .zip files. After unpacking the distribution, build it using the appropriate instructions for your platform later in this section.

To install an RPM package, use this command to create binary RPM packages that you can install. If you do not have rpmbuild, use rpm instead.

shell> rpmbuild --rebuild --clean PACKAGE.src.rpm

The command should produce binary shared and devel RPM packages and indicate where it placed them. You can install these packages using the instructions in Section 22.5.4.1, "Installing MySQL Connector/C from a Binary Distribution".

Building MySQL Connector/C on Unix from Source

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 cmake.org.

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 MySQL 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 MySQL Connector/C Build Options.

  3. Build the project:

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

    root-shell> make install

Building MySQL Connector/C on Microsoft Windows from Source

MySQL Connector/C can be built on several versions of Microsoft Windows, listed in Section 22.5.2, "MySQL Connector/C Supported Platforms".

Microsoft 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 cmake.org.

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 MySQL 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> devenv.com libmysql.sln /build
                        Release
    shell> devenv.com 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=Debugshell> devenv.com
                        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 MySQL Connector/C headers, libraries, and utilities. You can also use this CMake command:

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

Other MySQL Connector/C Build Options

The following tables show other options that can be used when building MySQL Connector/C from source.

Table 22.30. Build Options for MySQL Connector/C 6.1

Build Option Description
-DWITH_SSL=system Enable dynamic linking to the system OpenSSL library.
-DWITH_ZLIB=system Enable dynamic linking to the system Zlib library.

Table 22.31. Build Options for MySQL Connector/C 6.0

Build Option Description
-DWITH_OPENSSL=1 Enable dynamic linking to the system OpenSSL library.
-DWITH_EXTERNAL_ZLIB=1 Enable dynamic linking to the system Zlib library.