Source Installation
The MySQL Connector/C++ is based on the MySQL client libary (MySQL C
API). Connector C/C++ is linked against the MySQL client library. You
need to have the MySQL client library installed in order to compile the
Connector/C++.
You also need to have the cross-platform build tool CMake 2.6.2 or newer. Check the README file for platform specific notes on Windows and SunOS.
Typically the MySQL client library gets installed by installing
the MySQL Server. However, check your operating system documentation for
other installation options. Please note also, that MySQL provides
downloads for certain platforms which contain no more than the required
client library. It is a common mistake, in particular on Windows, to mix
header files and binaries from different MySQL client libraries. Of
course, this will cause issues.
[edit] Building on Unix, Solaris and Mac
1. Run CMake to build a Makefile
me@host:/path/to/mysql-connector-cpp> cmake .
-- Check for working C compiler: /usr/local/bin/gcc
-- Check for working C compiler: /usr/local/bin/gcc -- works
[...]
-- Generating done
-- Build files have been written to: /path/to/mysql-connector-cpp/
Read on at point 3.) in case of configure problems.
2. Use make to build the libraries
me@host:/path/to/mysql-connector-cpp> make clean
me@host:/path/to/mysql-connector-cpp> make
[ 1%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_connection.o
[ 3%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_constructed_resultset.o
[...]
[100%] Building CXX object examples/CMakeFiles/statement.dir/statement.o
Linking CXX executable statement
If all goes well, you will find the Connector/C++ library in
/path/to/cppconn/libmysqlcppconn.so
. In case of problems read on below before you ask for assistance.
3. CMake options: MySQL installation path, debug version and more
In case of configure and/or compile problems check the list of CMake options:
me@host:/path/to/mysql-connector-cpp> cmake -L
[...]
CMAKE_BACKWARDS_COMPATIBILITY:STRING=2.4
CMAKE_BUILD_TYPE:STRING=
CMAKE_INSTALL_PREFIX:PATH=/usr/local
EXECUTABLE_OUTPUT_PATH:PATH=
LIBRARY_OUTPUT_PATH:PATH=
MYSQLCPPCONN_GCOV_ENABLE:BOOL=0
MYSQLCPPCONN_TRACE_ENABLE:BOOL=0
MYSQL_CONFIG_EXECUTABLE:FILEPATH=/usr/bin/mysql_config
For example, if your MySQL Server installation path is not
/usr/local/mysql
and you want to build a debug version of the MySQL Connector/C++ use:
me@host:/path/to/mysql-connector-cpp> cmake -D CMAKE_BUILD_TYPE:STRING=Debug -D MYSQL_CONFIG_EXECUTABLE=/path/to/my/mysql/server/bin/mysql_config .
Verify your settings with
cmake -L
:
me@host:/path/to/mysql-connector-cpp> cmake -L
[...]
CMAKE_BACKWARDS_COMPATIBILITY:STRING=2.4
CMAKE_BUILD_TYPE:STRING=
CMAKE_INSTALL_PREFIX:PATH=/usr/local
EXECUTABLE_OUTPUT_PATH:PATH=
LIBRARY_OUTPUT_PATH:PATH=
MYSQLCPPCONN_GCOV_ENABLE:BOOL=0
MYSQLCPPCONN_TRACE_ENABLE:BOOL=0
MYSQL_CONFIG_EXECUTABLE=/path/to/my/mysql/server/bin/mysql_config
Procees with
make clean; make
as described at point 2.)
[edit] Building on Windows
The basic steps for building the driver on Windows are the same as on Unix: use CMake 2.6.2 or newer to generate build files for your compiler and compile the driver using your compiler.
We are sorry but we cannot formally support other compilers than Microsoft Visual Studio 2003 and above.
Thanks to CMake it is easy for you to try out other compilers.
However, you may experience compile warnings, compile errors or linking
issues not detected by Visual Studio. We appreciate your patches to fix
any of them.
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
("generators") than supported by MySQL Connector/C++. We have built the
driver 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 above Installation instructions for Unix, Solaris and Mac for troubleshooting and configuration hints.
Experimental support for additional generators is discussed outside this wiki:
- MINGW Makefiles: http://forums.mysql.com/read.php?117,425191,425191#msg-425191
1. Run CMake to generate build files for your "generator"
1.1 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
1.2 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
2. Use your compiler to build the MySQL Conenctor/C++
2.1 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 non-debug versions.
2.2 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
[edit] Platform Notes on Building
All distributions contain a README file. At the end of the README
file contained in a binary distribution you will find the settings used
to build the binaries.
If you experience build issues on a platform, it may help to
check the settings we use on the platform to build the binary by
downloading the binary package.
We have summarized further details at the wiki page Connector C++ Binary Builds.
[edit] Getting Started: Usage Examples
The download package contains usage examples in the directory
examples/. The examples explain the basic usage of the following
classes:
- Connection
- DatabaseMetaData
- Driver
- PreparedStatement
- ResultSet
- ResultSetMetaData
- Statement
The examples cover:
- Using the Driver class to connect to MySQL
- Creating tables, inserting rows, fetching rows using (simple) statements
- Creating tables, inserting rows, fetching rows using prepared statements
- Hints for working around prepared statement limitations
- Accessing result set meta data
- Accessing database meta data
The examples on this wiki page are only code snippets. The code
snippets provide a brief overview on the API. They are not complete
programs. Please check the examples/ directory for complete programs.
The examples will be compiled as part of a normal build (e.g. during make).
Τhank уou foг the ausрicious writеuρ.
It in realіty wаs onсe a lеisurе account it.
Loоκ complіcаted to far added agreeable from you!
Howeѵеr, how can ωе be in сontact?
My pаge; CarbonPoker Bonus
my website: http://chatstudents.co.uk/
Thiѕ blog was... how do I say іt? Releνant!
! Finally I've found something which helped me. Kudos!
My homepage :: WebRead
Hеllο theге, Yοu've done a great job. I will definitely digg it and personally suggest to my friends. I'm ѕure they'll be benefited from this site.
Also visit my website ... CarbonPoker Promotions
A person necessarily lend a hand to make significantly posts I would state.
That is the first time I frequented your website page and
so far? I surprised with the analysis you made to make
this actual submit amazing. Excellent activity!
My web blog Holdem Poker