Currently MySQL connector/c++ binary version of the highest only support vs2008,vs2015 need to download source code self-compiled.
Although the MySQL manual provides information, there are a number of details to note during the compilation process.
CMAKE
Download the latest stable version on the website
Add the Bin directory to the environment variable path
Boost
Also to the official website to download the latest stable version
MySQL Client library
MySQL Client library header file in the Include directory under MySQL directory
Yes, compiling connector also requires downloading a MySQL Server
Add the environment variable Mysql_dir, the value is the MySQL server root directory
CMake will find the header file under Mysql_dir/include
Download MySQL connector/c++ source code
http://dev.mysql.com/downloads/connector/cpp/
Select "Source Code" in "Select Platform"
Download unzip
Build vs Solution file
Open a CMD window and go to the extracted MySQL connector root directory
Perform
Cmake-g "Visual Studio Win64"-dboost_root: STRING=d:/bin/boost159
which
- Win64 is very important, otherwise the x86 solution is generated.
- -dboost_root:string declares the root directory of the Boost library, setting its value according to its own configuration.
compiling MySQL Connector
In the MySQL connector root directory, you can see the generated. sln file, double-click Open
Dozens of engineering documents, in addition to libraries including examples, tests, etc.
In the Solution Explorer window, locate the Mysqlcppconn project, right-click, select Build
Failed......
In the "Output" window, select output from "Generate", Ctrf+f, search "error", you can see
>c:\program Files (x86) \ Windows Kits\10\include\10.0.10150.0\ucrt\stdio.h (1927): Fatal error C1189: #error: Macro Definition of snprintf conflicts with standard Library function declaration
The previous line is
2> d:\bin\mysql-connector-c++-1.1.6\driver\nativeapi/mysql_private_iface.h: NOTE: See the previous definition of "snprintf"
Double-click on this line, navigate to the 48 line of Mysql_private_iface.h, comment out
// #if (defined (_WIN32) | | defined (_WIN64)) &&!defined (snprintf) // #define SNPRINTF _snprintf // #endif
In the Output window, select the output from "Generate", click "Remove all" to generate the project again
Failed...... Once again
Look at the generated information again, the same problem
Double-click to navigate to the 516 line of m_config.h, and note the
// #define SNPRINTF _snprintf
Re-build
After flashing a few screens of warning message, the compilation succeeds
Compile all
In the Solution Explorer window, right-click the solution and select Build Solution
Finally more than 10 projects, more than 10 projects failed to ignore the failure
At this time to get VS2015 library files, examples of engineering
Visual Studio 2015 compiles 64-bit MySQL connector/c++