Please note the only compiler formally supported for Windows is Microsoft Visual Studio 2003 and above.
The basic steps for building the connector on Windows are the same as for Unix. It is important to use CMake 2.6.2 or newer to generate build files for your compiler and to invoke the compiler.
On Windows, mysql_config
is not present, so
CMake will attempt to retrieve the location of MySQL from the
environment variable $ENV{MYSQL_DIR}
. If
MYSQL_DIR
is not set, CMake will then
proceed to check for MySQL in the following locations:
$ENV{ProgramFiles}/MySQL/*/include
, and
$ENV{SystemDrive}/MySQL/*/include
.
CMake makes it easy for you to try out other compilers. However, you may experience compile warnings, compile errors or linking issues not detected by Visual Studio. Patches are gratefully accepted to fix issues with other compilers.
Consult the CMake manual or check cmake
--help
to find out which build systems are supported
by your CMake version:
C:\>cmake --help cmake version 2.6-patch 2 Usage [...] Generators The following generators are available on this platform: Borland Makefiles = Generates Borland makefiles. MSYS Makefiles = Generates MSYS makefiles. MinGW Makefiles = Generates a make file for use with mingw32-make. NMake Makefiles = Generates NMake makefiles. Unix Makefiles = Generates standard UNIX makefiles. Visual Studio 6 = Generates Visual Studio 6 project files. Visual Studio 7 = Generates Visual Studio .NET 2002 project files. Visual Studio 7 .NET 2003 = Generates Visual Studio .NET 2003 project files. Visual Studio 8 2005 = Generates Visual Studio .NET 2005 project files. Visual Studio 8 2005 Win64 = Generates Visual Studio .NET 2005 Win64 project files. Visual Studio 9 2008 = Generates Visual Studio 9 2008 project fil Visual Studio 9 2008 Win64 = Generates Visual Studio 9 2008 Win64 proje files. [...]
It is likely that your CMake binary will support more compilers, known by CMake as generators, than supported by MySQL Connector/C++. We have built the connector using the following generators:
Microsoft Visual Studio 8 (Visual Studio 2005)
Microsoft Visual Studio 9 (Visual Studio 2008, Visual Studio 2008 Express)
NMake
Please see the building instructions for Unix, Solaris and Mac OS X for troubleshooting and configuration hints.
The steps to build the connector are given below:
Run CMake to generate build files for your generator:
Visual Studio
C:\path_to_mysql_cpp>cmake -G "Visual Studio 9 2008" -- Check for working C compiler: cl -- Check for working C compiler: cl -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: cl -- Check for working CXX compiler: cl -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- ENV{MYSQL_DIR} = -- MySQL Include dir: C:/Programme/MySQL/MySQL Server 5.1/include -- MySQL Library : C:/Progams/MySQL/MySQL Server 5.1/lib/opt/mysqlclient.lib -- MySQL Library dir: C:/Progams/MySQL/MySQL Server 5.1/lib/opt -- MySQL CFLAGS: -- MySQL Link flags: -- MySQL Include dir: C:/Progams/MySQL/MySQL Server 5.1/include -- MySQL Library dir: C:/Progams/MySQL/MySQL Server 5.1/lib/opt -- MySQL CFLAGS: -- MySQL Link flags: -- Configuring cppconn -- Configuring test cases -- Looking for isinf -- Looking for isinf - not found -- Looking for isinf -- Looking for isinf - not found. -- Looking for finite -- Looking for finite - not found. -- Configuring C/J junit tests port -- Configuring examples -- Configuring done -- Generating done -- Build files have been written to: C:\path_to_mysql_cpp C:\path_to_mysql_cpp>dir *.sln *.vcproj [...] 19.11.2008 12:16 23.332 MYSQLCPPCONN.sln [...] 19.11.2008 12:16 27.564 ALL_BUILD.vcproj 19.11.2008 12:16 27.869 INSTALL.vcproj 19.11.2008 12:16 28.073 PACKAGE.vcproj 19.11.2008 12:16 27.495 ZERO_CHECK.vcproj
NMake
C:\path_to_mysql_cpp>cmake -G "NMake Makefiles" -- The C compiler identification is MSVC -- The CXX compiler identification is MSVC [...] -- Build files have been written to: C:\path_to_mysql_cpp
Use your compiler to build MySQL Connector/C++
Visual Studio - GUI
Open the newly generated project files in the Visual Studio GUI or use a Visual Studio command line to build the driver. The project files contain a variety of different configurations. Among them debug and nondebug versions.
Visual Studio - NMake
C:\path_to_mysql_cpp>nmake Microsoft (R) Program Maintenance Utility Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. Scanning dependencies of target mysqlcppconn [ 2%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_connection.obj mysql_connection.cpp [...] Linking CXX executable statement.exe [100%] Built target statement
User Comments
Add your own comment.