<<toc>>
The Windows build process for MariaDB 5.2 and later is compatible with
MySQL5.5, so you can use the instructions on
the [[http://forge.mysql.com/wiki/CMake|MySQL CMake Wiki]]. Also, detailed
step-by-step instructions for Visual Studio Express users are available
[[http://sleto.wordpress.com/2010/11/26/step-by-step-guide-on-how-to-compile-mysql-5-5-on-microsoft-windows|here]].
The instructions here do not assume knowledge of the above two sources.
== Build Requirements
To build MariaDB you need the following:
* [[http://www.microsoft.com/visualstudio|Visual C++]]: We currently support
Visual Studio 2008 and 2010, including the (free) express editions (generally we try
to support the two most recent versions). Install latest service packs as
well, which are (as of when this was written) SP1 for both VS2008 and VS2010.
* [[http://wiki.bazaar.canonical.com/WindowsDownloads|Bazaar]]: Required to
build from the source tree. Use the standalone installer and choose the
default install options.
* [[http://www.cmake.org/cmake/resources/software.html|CMake 2.8]]: The build
system.
* [[http://gnuwin32.sourceforge.net/packages/bison.htm|Bison from GnuWin32]]:
Bison creates parts of the SQL parser. Choose "Complete package except
sources" when downloading.
** NOTE: ** Do not** install this into your default path with spaces
(e.g. under ##C:\Program Files\GnuWin32##), the build will break due to
[[http://sourceforge.net/tracker/index.php?func=detail&aid=2788969&group_id=23617&atid=379173|this bison bug]].
Instead, install into ##C:\GnuWin32## instead.
** Add ##C:\GnuWin32\bin## to your system ##PATH## after installation.
* [[http://strawberryperl.com|Strawberry perl]]: Used to run the test suite.
[[http://www.activestate.com/activeperl/downloads|ActiveState Perl]] is
another Win32 Perl distribution and should work as well (but it is not as
well tested).
* Optional: If you intend to build the MSI packages, install
[[http://wix.codeplex.com/releases| Windows Installer XML version 3.0 or higher]]
* Optional: [[http://gnuwin32.sourceforge.net/packages/diffutils.htm |Gnu Diff]], recommended for MariaDB developers, it improves error output of test utility mysql-test-run.pl
Verify that bison.exe, bzr.exe, cmake.exe and perl.exe can be found in PATH
environment variable, with "##where bison##", "##where bzr##", and etc... from
the command line prompt.
== Building Windows Binaries
The above instructions assume MariaDB 5.2 or higher. For instructions how to
build 5.1, look in the section "Old Style Build".
Branch the MariaDB bzr repository, or unpack the source archive. On the command
prompt, switch to your source directory, then execute:
<<code>>
mkdir bld
cd bld
cmake ..
cmake --build . --config Relwithdebinfo
<</code>>
The above example builds a release configured for 32 bit systems in a
subdirectory named ##bld##. "##cmake ...##" is the configuration step,
"##cmake --build . --config Relwithdebinfo##" is the build step.
== Build Variations:
=== Debug builds
Building Debug version is done with:
<<code>>
cmake --build . --config Debug
<</code>>
=== x64 builds
By default, cmake will create 32 bit projects. For 64 bit, you must pass CMake
the "generator" parameter using -G in the configuration step, e.g.:
<<code>>
cmake .. -G "Visual Studio 10 Win64"
<</code>>
for VS2010 or
<<code>>
cmake .. -G "Visual Studio 9 2008 Win64"
<</code>>
for VS2008.
For complete list of available generators, call "cmake" without any parameters.
=== IDE builds
Instead of calling "##cmake --build##" as above, open ##MySQL.sln##. When Visual Studio starts, choose Build/Compile.
=== NMake builds
Ensure the Visual Studio environment variable are correctly set, e.g. build
from "Visual Studio 2010 Command prompt" (Start=>All Programs=>Microsoft Visual
Studio 2010=>Visual Studio tools=>Visual Studio Commad Prompt (2010)). It can
be convenient to create a shortcut from to "Visual Studio Command Prompt(2010)
on the desktop (navigate in start menu to find it, then rightclick=>Send
To=>Desktop (create shortcut)" On the command line, execute
<<code>>
mkdir bld
cd bld
cmake .. -G "NMake Makefiles"
nmake
<</code>>
You can optionally pass ##-DCMAKE_BUILD_TYPE={Debug|RelWithDebInfo}## to cmake
to build either debug or release.
=== devenv builds
Ensure the Visual Studio environment variable are correctly set (see above).
to build, execute
<<code>>
devenv mysql.sln /build relwithdebinfo
<</code>>
or, for debug builds
<<code>>
devenv mysql.sln /build debug
<</code>>
== Optional build parameters
[[http://forge.mysql.com/wiki/CMake|MySQL CMake Wiki]] describes how to use
optional parameters in build. Perhaps single important parameter in MariaDB is
##WITH_EMBEDDED_SERVER## (build with embedded server). It is not set by default
in the build, since it effectively doubles the compilation time. Use
<<code>>cmake -DWITH_EMBEDDED_SERVER=1<</code>> to enable embedded builds.
== Building the ZIP package
<<code>>
cmake --build . --config relwithdebinfo --target package
<</code>>
== Building the MSI package
<<code lang=sh inline=false>>cmake --build . -- config relwithdebinfo --target msi<</code>>
Some versions of CMake 2.8 (up to 2.8.3) require slightly different commands
for building an MSI with VS2010
<<code lang=sh inline=false>>cmake --build . --config relwithdebinfo --target win/packaging/msi<</code>>
== Including HeidiSQL in the MSI installer
Starting with MariaDB 5.2.7, it is possible to build an installer which
includes 3rd party products, as described in
[[http://askmonty.org/worklog/Other/?tid=200|MWL#200]]. Currently only
[[http://wwww.heidisql.com|HeidiSQL]] support is implemented, it is also
included in the official builds. Use CMake parameter
##-DWITH_THIRD_PARTY=HeidiSQL## to include it in the installer.
== Code signing support for MariaDB release processing
MariaDB builds optionally support authenticode code signing with an optional
parameter ##SIGNCODE##. Use <<code>>cmake -DSIGNCODE=1<</code>> during the
configuration step to sign the binaries in the ##ZIP## and ##MSI## packages.
**Important:** for ##SIGNCODE=1## to work, the user who runs the build needs to
install a valid authenticode digital certificate into his certificate store,
otherwise the packaging step will fail.
== Building packages for MariaDB releases
The full script to create the release in an out-of-source build with Visual
Studio 2010 with signed binaries might look like:
<<code>>
mkdir bld
cd bld
cmake .. -DWITH_EMBEDDED_SERVER=1 -DSIGNCODE=1 -DWITH_THIRD_PARTY=HeidiSQL
cmake --build . --config relwithdebinfo --target package
cmake --build . --config relwithdebinfo --target msi
<</code>>
This command sequence will produce a ZIP package (e.g mariadb-5.2.6-win32.zip)
and MSI package (e.g mariadb-5.2.6-win32.msi) in the ##bld## directory.
== Old-style building (MariaDB 5.1)
The difference between legacy MariaDB 5.1 builds vs later versions is:
* 5.1 cannot be built out-of-source.
* 5.1 requires an additional step (win\configure-mariadb.bat) during
configuration.
* 5.1 requires a prepackaged source distribution (made on Unix only) to create
the ZIP package. It also requires Cygwin to create the ZIP.
* 5.1 does not feature the new MSI installer, instead NSIS is used. Building
NSIS also requires the pre-packaged source distribution and cannot be made
from a bzr repository.
Here is how to build 5.1:
<<code>>
win\configure-mariadb.bat
cmake .
cmake . --build relwithdebinfo
<</code>>
=== ZIP packaging in 5.1
The process for producing the 5.1 binary ZIP is as follows:
* Make the source tarball. This can only be done on Unix (we use Linux) by
running <<code>>BUILD/compile-dist && make dist<</code>>.
See [[Creating the MariaDB Source Tarball]] for full instructions.
** In BuildBot, this is done using the
[[http://askmonty.org/buildbot/builders/hardy-amd64-makedist/|hardy-amd64-makedist]]
builder.
* Compile and package on Windows. This is done by unpacking the source tarball
on Windows and running <<code>>sh win/make_mariadb_win_dist<</code>>.
** In Buildbot, this done by the
[[http://askmonty.org/buildbot/builders/win32-make-noinstall-zip/|win32-make-noinstall-zip]]
builder.
=== NSIS installer in 5.1
If you want to create the release, you also need
[[http://nsis.sourceforge.net|NSIS]].
Build the server as usual. You should then build the release, not debug or any
other. When the server has been built, simply run "<<code>>cpack<</code>>" in
the top directory to create the .exe package.
== Miscellaneous
* In 5.2 and later, Cygwin is not required for any build step and is not
supported. Don't use it, if you can.
* To compile OQGRAPH engine, Boost needed to be installed. Download Boost
redistribution from http://www.boost.org/ and unpack it. Set environment
variable BOOST_ROOT to point to the directory where you unpacked boost in the
previous step. Note: OQGRAPH build is currently disabled on x64 due to lpbug:756966