Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Connector C++ 64bit build from source in Visual Studio 2012

I am trying to build the mySQL Connector C++ from source in Visual Studio 2012 for the 64-bit architecture. I understand that it depends on some boost header files and the C connector. Running CMake produces a project file, but that project file doesn't compile because of a big list of very confusing errors which probably have to do something with the include files, and an even bigger list of warnings. The official site is of little help.

Could some one please list all the steps in successfully compiling the C++ Connector?

like image 418
Lefteris E Avatar asked Jan 11 '23 19:01

Lefteris E


1 Answers

In order to build it you need to have the following:

  1. You need to have installed either the MySQL server or the MySQL C Connector.
  2. Have installed the Boost C++ libraries or have the source files for it. Please note that there is not need to build boost as you only need the header files.
  3. Have CMake installed. When installing CMake it will ask you if you want it included in the PATH variable, you should select yes to make it easier later to use it.

Once you have all three available, open VS2012 x64 Native Tools Command Prompt and from the source root directory of the MySQL C++ Connector you need to issue the following:

set MYSQL_DIR=c:\PROGRA~1\MySQL\MYSQLC~1.1
cmake -G "Visual Studio 11 Win64" ^
      -DBOOST_ROOT:STRING=C:\Users\user\DOWNLO~1\BOOST_~1\BOOST_~1 ^
      -DMYSQL_LIB_DIR:STRING=c:\PROGRA~1\MySQL\MYSQLC~1.1\LIB
devenv.com MySQLCPPCONN.sln /build Release

The first command defines the MYSQL_DIR variable that points to the installation of the MySQL server or the MySQL C Connector. The second command call cmake to prepare a VS project that will be 64bit. There seems to be a problem with the MYSQL_LIB_DIR variable and it does not get generated, so we need to define it manually. MYSQL_LIB_DIR has the value of MYSQL_DIR ending with a \LIB. Third command is optional, it will build the project from command prompt without opening VS.

It is recommended that you use the DOS paths for the variables. To do that, navigate to the directory you want to convert to DOS path and call for %I in (.) do echo %~sI. It will give you the converted path.

like image 126
George Michael Avatar answered Jan 22 '23 04:01

George Michael