Transactd Build Guide for Windows

1. Prepare the environment

Transactd Plugin and clients can be built with Visual Studio on Windows (32bit/64bit).
Transactd Plugin will build with MySQL.It will build the compiler to request of MySQL.
MySQL 5.7 is Visual Studio Express 2013, a version of MySQL / MariaDB otherwise you build using Visual Studio Express 2010.

(The clients can be compiled with Embarcadero C++ Builder XE series. Please refer to Build clients section.)

MySQL 5.7, You download and install the following compiler.

MySQL 5.5/5.6、MariaDB 5.5/10.0, You download and install the following compiler and SDK.

How to start the Visual Studio Command Prompt

In procedure which will be described later. you should open the Visual Studio command prompt. Open it from [Start menu] - [All Programs] - [Microsoft Visual Studio 2010 Express] - [Visual Studio Command Prompt(2010)].

Visual Studio command prompt for 64bit version of build tools is not included in Visual Studio 2010 Express. Instead, create a batch file to set the path for 64bit build tool, and start from there. Create a file containing the following, and then save it as set64env.cmd on desktop.

%comspec% /k "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64

In procedure which will be described later.
MySQL 5.5/5.6、MariaDB 5.5/10.0, you should open the Visual Studio command prompt in the following procedure.

MySQL 5.7, you should open the Visual Studio command prompt in the following procedure.

2. Download and install CMake

Download CMake Win32 Installer from CMake download page and run it.

Along the way, select "Add CMake to the system PATH for all (or current) users" to set path of cmake.exe.

3. Download and install Boost C++ Libraries

Since the BoostPro download page has been closed, it is no longer possible to download pre-built binaries. Build it from source code.

Build from source

Download source code from Boost download page and unzip it. Here, it is assumed that you have saved in the following folder:

C:\boost\boost_1_55_0

Start the Visual Studio command prompt. Run the following commands to build Boost:

cd C:\boost\boost_1_55_0
bootstrap.bat

@REM Visula studio 2010 64bit
bjam.exe toolset=msvc-10.0 threading=multi address-model=64 architecture=x86 ^
  --with-chrono --with-filesystem --with-system --with-thread --with-timer ^
  --with-serialization --with-program_options ^
  variant=debug,release link=static runtime-link=static,shared

@REM Visula studio 2010 32bit
bjam.exe toolset=msvc-10.0 threading=multi architecture=x86 ^
  --with-chrono --with-filesystem --with-system --with-thread --with-timer ^
  --with-serialization --with-program_options ^
  variant=debug,release link=static runtime-link=static,shared

@REM Visula studio 2013 64bit
bjam.exe toolset=msvc-12.0 threading=multi address-model=64 architecture=x86 ^
  --with-chrono --with-filesystem --with-system --with-thread --with-timer ^
  --with-serialization --with-program_options ^
  variant=debug,release link=static runtime-link=static,shared

@REM Visula studio 2013 32bit
bjam.exe toolset=msvc-12.0 threading=multi architecture=x86 ^
  --with-chrono --with-filesystem --with-system --with-thread --with-timer ^
  --with-serialization --with-program_options ^
  variant=debug,release link=static runtime-link=static,shared

4. Build both of the Plugin and clients

Please skip this step if you want to build only the clients.

4-1 Download MySQL source code

Download source code from MySQL Community Server download page.

Select [Select Platform] - [Source Code] and choose Windows Zip file.

Unzip the downloaded file. Here, it is assumed that you have saved in the following folder:

C:\Users\Public\Documents\mysql-5.6.25

4-2 Download Transactd Plugin source code

Download the source code from Transactd Plugin download page.

Make folder transactd in MySQL plugin folder:

md C:\Users\Public\Documents\mysql-5.6.25\plugin\transactd

Extract it into the plugin directory in the MySQL source code directory. In this case, the folder structure as follows:

C:\Users\Public\Documents\mysql-5.6.25\plugin\transactd

4-3 Modify MySQL source code

4-3.1 Apply patch

Patch to fix a few files of MySQL source code is included in patch directory of Transactd Plugin source code. Copy it to MySQL source code directory. (Patch has a different name for each version of the MySQL / MariaDB.)

cd C:\Users\Public\Documents\mysql-5.6.25
copy plugin\transactd\patch\transactd-win-mysql-5.6.25.patch *

If you have the environment which contains patch command (such as Cygwin Git Bash etc), apply the patch with the following command:

cd C:\Users\Public\Documents\mysql-5.6.25
patch -p0 -i transactd-win-mysql-5.6.25.patch

If there is no patch command, download and use GNU Patch 2.5.4 (Win32 version) by Ken Miyasaka. Here, it is assumed that you have saved in the following folder:

C:\Program Files (x86)\patc254w

Then apply the patch with the following command:

cd C:\Users\Public\Documents\mysql-5.6.25
"C:\Program Files (x86)\patc254w\patch.exe" -p0 --binary -i transactd-win-mysql-5.6.25.patch

4-3.2 Modify the encoding of source code

If you want to build on Japanese Windows environment, you must change the encoding of a few source code. Open the following files from Visual Studio, [Save As] - click right side of [Save] - Select [Save with Encoding] - save with "Unicode (UTF-8 with signature) - code page 65001".

4-4 Run CMake

Start the Visual Studio command prompt, run the following commands:

@REM Visual studio 2010 64Bit 
cd C:\Users\Public\Documents\mysql-5.6.25
md x64
cd x64
cmake .. -G "Visual Studio 10 Win64" ^
   -DBOOST_ROOT="C:\boost\boost_1_58_0"

@REM Visual studio 2013 64Bit
cd C:\Users\Public\Documents\mysql-5.7.8
md x64
cd x64
cmake .. -G "Visual Studio 12 Win64" ^
   -DWITH_BOOST="C:\boost\boost_1_58_0" ^
   -DBOOST_ROOT="C:\boost\boost_1_58_0"

4-5 Build

CMake is complete, then the following solution file is generated:

C:\Users\Public\Documents\mysql-5.6.25\bldVC100x64\MySQL.sln

Open MySQL.sln with Visual Studio. Change the configuration to "Release" from menu [Build] - [Configuration Manager]. Then click [Build] - [Build Solution].

Binary will be output in the following folders:

C:\Users\Public\Documents\mysql-5.6.25\bldVC100x64\sql\lib\plugin
C:\Users\Public\Documents\mysql-5.6.25\bldVC100x64\plugin\transactd\bin
C:\Users\Public\Documents\mysql-5.6.25\bldVC100x64\plugin\transactd\lib

5. Build clients

Prease refer to Notes to build clients on Windows too.

5-1 Download Transactd source code

Download the source code from Transactd Plugin download page.

Here, it is assumed that you have saved in the following folder:

C:\Users\Public\Documents\transactd

(Skip to Build with C++BuilderXE series if you use Embarcadero C++BuilderXE series.)

5-2 Run CMake

Start the Visual Studio command prompt, run the following commands:

@REM Visual studio 2010 64Bit
cd C:\Users\Public\Documents\transactd
md x64
cd x64
cmake .. -G "Visual Studio 10 Win64" ^
  -DBOOST_ROOT="C:\boost\boost_1_58_0"  ^
  -DWITH_TRANSACTD_SERVER=OFF -DWITH_TRANSACTD_CLIENTS=ON

@REM Visual studio 2013 64Bit
cd C:\Users\Public\Documents\transactd
md x64
cd x64
cmake .. -G "Visual Studio 12 Win64" ^
  -DBOOST_ROOT="C:\boost\boost_1_58_0" ^
  -DWITH_TRANSACTD_SERVER=OFF -DWITH_TRANSACTD_CLIENTS=ON

5-3 Build

CMake is complete, then the following solution file is generated:

C:\Users\Public\Documents\transactd\bldVC100x64\TransactdClinet.sln

Open tdcl.sln with Visual Studio. Change the configuration to "Release" from menu [Build] - [Configuration Manager]. Then click [Build] - [Build Solution].

Binary will be output in the following folders:

C:\Users\Public\Documents\transactd\bldVC100x64\bin
C:\Users\Public\Documents\transactd\bldVC100x64\lib

5-4 Build with C++BuilderXE series

With Embarcadero C++BuilderXE series, use project file:

C:\Users\Public\Documents\Build\TransactdClient_bcb.groupproj

The boost libraries which is bundled to compiler are required.

Add following paths to C++ Builder [tool] - [options] - [environment options] - [C++ options] - [path and directory] - [system include path]:

32Bit $(CG_BOOST_ROOT)
64Bit $(CG_64_BOOST_ROOT)

There are build types, Unicode/Ansi, Release/Debug, 32Bit/64Bit. Output files will be generated to bin lib folders. Linking to dynamic RTL is required in 64Bit version.

Some repletions for each versions are below.

On the all XE version with 32Bit, boost_program_options is not compiled. Generate libboost_program_options-bcb-mt-1_39.lib with the project file:

build\libboost_program_options-bcb1_39\libboost_program_options-bcb-mt-1_39.cbproj

Before compile it, need to some fix:

file     :$(CG_BOOST_ROOT)\boost_1_39\libs\program_options\src\variables_map.cpp
line 71  :v = variable_value();  -->  variable_value vr;v = vr;
line 115 :m[key] = variable_value(def, true);  -->  variable_value vr(def, true);m[key] = vr;

On XE2, boost_serialization is not compiled. Generate libboost_serialization-bcb-mt-1_39.lib with the project file:

build\libboost_serialization-bcb-1_39\libboost_boost_serialization-bcb-mt-1_39.cbproj

On XE4 64Bit, it has the same compiler version with XE3, tdclcpp's auto linker will search tdclcpp_bc170_64x.lib. But the output file is tdclcpp_bc180_64x.dll on XE4, so link error will occur. To avoid this problem, rename lib file name to tdclcpp_bc180_64x_xx.lib or tdclstmt_bc180_64x_xx.lib.

On XE6 64Bit, we can not compile boost_thread. Fix source file:

file   :$(CG_BOOST_ROOT)\boost_1_50\boost\asio\detail\impl\win_thread.ipp
line 52:  ::QueueUserAPC(apc_function, thread_, 0); --> ::QueueUserAPC((PAPCFUNC)apc_function, thread_, 0);