1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
|
MySQL Connector/C++
Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems Inc.
CONTENTS
* Contact
* Installation
* Prerequisites for building Connector/C++
* Building on Unix
* Run CMake to build a Makefile
* Use make to build the libraries
* CMake options: MySQL installation path, debug version and more
* Building on Solaris
* Building on Windows
* Source layout
* (if binary package) Further Platform Notes on Building
CONTACT
For general discussion of the MySQL Connector/C++ please use the C/C++
community forum at http://forums.mysql.com/list.php?167 or join the MySQL
Connector/C++ mailing list at http://lists.mysql.com .
Bugs can be reported at http://bugs.mysql.com .
For sales related questions please write to <sales@mysql.com>.
See also http://forge.mysql.com/wiki/Connector_C%2B%2B .
INSTALLATION
The MySQL Driver for C++ is distributed in source and binary form.
The binary distributions are available as TAR.GZ archives for all
supported platforms but Windows. On Windows you either use a MSI Installer
or unpack a ZIP archive to an appropriate place.
Please check the Reference Manual for further information at:
http://dev.mysql.com/doc/refman/5.1/en/connector-cpp.html
Notes on building the driver from source can be found in the Reference
Manual and below. At the end of this file you may find settings
we have used to build a binary package for your platform.
PREREQUISITES FOR BUILDING CONNECTOR/C++
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++.
Typically the MySQL client library gets installed by installing
the MySQL Server. However, check your operating system documentation for
other installation options.
Alternatively you can install the new MySQL Connector/C. The MySQL Connector/C
is a standalone version of the MySQL client library.
You need to have CMake 2.6.2 (http://www.cmake.org).
NOTE: cmake binaries are available for most systems. You do not need to build
cmake yourself.
As of version 1.1.0 Connector/C++ makes use of Boost (http://www.boost.org).
You need to have Boost 1.34.0 or newer installed on your build system.
The MySQL driverfor C++ makes use of Boost variant, any and some pointers.
All of those are "headers only". When installing Boost on your system,
you can disable all components that require building any kind
of binaries.
BUILDING ON UNIX
The MySQL Connector/C++ is using the cross platform make CMake. CMake
creates classical Makefiles. Please visit http://www.cmake.org for
further information and documentation.
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
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- mysql_config was found /usr/bin/mysql_config
-- MySQL Include dir: /usr/include/mysql
-- MySQL Library :
-- MySQL Library dir: /usr/lib64/mysql;/usr/lib64
[...]
-- Configuring done
-- 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
Scanning dependencies of target mysqlcppconn
[ 0%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_art_resultset.cpp.o
[ 1%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_art_rset_metadata.cpp.o
[ 2%] Building CXX object driver/CMakeFiles/mysqlcppconn.dir/mysql_connection.cpp.o
[...]
[100%] Building CXX object test/unit/template_bug_group/CMakeFiles/bug456.dir/bug456.o
Linking CXX executable bug456
If all goes well, you will find the Connector/C++ library in
/path/to/driver/libcppmysqlcppconn.so . In case of problems read on below
before you ask for assistance.
If you want to install the libraries on your system proceed with make install.
me@host:/path/to/mysql-connector-cpp> make install
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_BUILD_TYPE:STRING=
CMAKE_INSTALL_PREFIX:PATH=/usr/local
MYSQLCLIENT_STATIC_BINDING:BOOL=1
MYSQLCPPCONN_BUILD_EXAMPLES:BOOL=1
MYSQLCPPCONN_DT_RPATH:STRING=
MYSQLCPPCONN_DYNLOAD_MYSQL_LIB:FILEPATH=/usr/lib64/libmysqlclient_r.so
MYSQLCPPCONN_GCOV_ENABLE:BOOL=0
MYSQLCPPCONN_ICU_ENABLE:BOOL=0
MYSQLCPPCONN_STLPORT_ENABLE:BOOL=0
MYSQLCPPCONN_TEST_NOT_IMPLEMENTED:BOOL=0
MYSQLCPPCONN_TRACE_ENABLE:BOOL=0
MYSQL_CONFIG_EXECUTABLE:FILEPATH=/usr/bin/mysql_config
You may also try cmake -LA to get a list of all options including
the advanced options.
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 -DCMAKE_BUILD_TYPE:STRING=Debug -DMYSQL_CONFIG_EXECUTABLE:FILEPATH=/path/to/my/mysql/server/bin/mysql_config .
Verify your settings with cmake -L:
me@host:/path/to/mysql-connector-cpp> cmake -L
[...]
CMAKE_BUILD_TYPE:STRING=
CMAKE_INSTALL_PREFIX:PATH=/usr/local
MYSQLCLIENT_STATIC_BINDING:BOOL=1
MYSQLCPPCONN_BUILD_EXAMPLES:BOOL=1
MYSQLCPPCONN_DT_RPATH:STRING=
MYSQLCPPCONN_DYNLOAD_MYSQL_LIB:FILEPATH=/usr/lib64/libmysqlclient_r.so
MYSQLCPPCONN_GCOV_ENABLE:BOOL=0
MYSQLCPPCONN_ICU_ENABLE:BOOL=0
MYSQLCPPCONN_STLPORT_ENABLE:BOOL=0
MYSQLCPPCONN_TEST_NOT_IMPLEMENTED:BOOL=0
MYSQLCPPCONN_TRACE_ENABLE:BOOL=0
MYSQL_CONFIG_EXECUTABLE:FILEPATH=/path/to/my/mysql/server/bin/mysql_config
Procees with make clean; make as described at point 2.)
NOTE: cmake does cache settings in the file CMakeCache.txt.
Make sure that cmake does not use old and unwanted settings from
CMakeCache.txt. This may cause compile problems. If so, delete CMakeCache.txt,
configure custom settings with cmake -D, if any and try compiling again.
BUILDING ON SOLARIS
Use the Sun compiler to build the MySQL Connector/C++.
Ensure that your environment points cmake to the appropriate compiler
binaries. The binary distributions of the MySQL Server are build using Sun
compilers. The MySQL tool mysql_config returns compiler flags suitable for
Sun compilers but possibly not suitable for GCC.
If you plan to use GCC on Solaris to compile MySQL Connector/C++,
you might need to insert
SET(MYSQL_CXXFLAGS "")
at the end of the file /path/to/mysql-connector-cpp/FindMySQL.cm.
However, its recommended to use Sun Studio on Solaris.
No changes are required when using the Sun compilers!
Make sure that you do not mix Sun compilers with GNU compilers when building
the MySQL Connector/C++. For example, do not use GCC as a C compiler and
Sun CC as a C++ compiler. The linker might fail to link the results
from both compilers to one binary.
BUILDING ON WINDOWS
The MySQL Connector/C++ is using the cross platform make CMake. CMake
creates classical Makefiles. Please visit http://www.cmake.org for
further information and documentation.
You need to have the environment variables set for the Visual Studio
toolchain. Visual Studio includes a batch file to set these for you,
and installs a shortcut into the Start menu to open a command prompt
with these variables set.
You need to set MYSQL_DIR to point to where the MySQL server is
installed, using the short-style filenames:
set MYSQL_DIR=C:\PROGRA~1\MySQL\MYSQLS~1.0
Build Connector/C++ using the "cmake" command-line tool by doing the
following from the source root directory (in a command prompt window);
cmake -G "Visual Studio 8 2005"
This produces a project file that you can open with Visual Studio or
build from the command line with either of:
devenv.com MySQLCPPCONN.sln /build Release
devenv.com MySQLCPPCONN.sln /build RelWithDebInfo
To compile the "Debug" build, you must run set the cmake build type so
the correct version of the MySQL client libraries are used:
cmake -G "Visual Studio 8 2005" -DCMAKE_BUILD_TYPE=Debug
devenv.com MySQLCPPCONN.sln /build Debug
Upon completion; you will find the executables in the subdirectories of the
"bin" and "lib" directories.
Different versions of CMake come with different "generators". A generator
is the component of CMake that is responsible for writing the build files.
If, for example, cmake --help does not list a generator for
Visual Studio 9 2008, try a more recent version of CMake.
Connector C/C++ supports only Microsoft Visual Studio 2003 and above
on Windows.
SOURCE LAYOUT
The MySQL Connector/C++ distribution contains the following directories:
|-- cppconn <-- Header files of the public interface
|-- driver <-- Connector/C++ source code
|-- examples <-- Basic examples
|-- test <-- Tests, so to say: more examples
|-- thread <-- Thread abstaction, unused
--- win <-- Windows MSI Installer
FURTHER PLATFORM NOTES ON BUILDING
If this README file is contained in a binary package, you will see below
what settings we have used to create the biary.
If this README file is contained in a source package and, you have build
issues, please download a binary package for your platform and check
the platform specific notes found in its README.
LEGAL
***************************************************************************
The following software may be included in this product:
Boost c++ libraries
Use of any of this software is governed by the terms of the license below:
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
***************************************************************************
|