For the brave: compiling Workbench 6.3 using Visual Studio 2013 on Windows

Compiling MySQL Workbench yourself is quite a common task for Linux users, even though the application is available precompiled for certain platforms ready from our download page and available in our yum and apt repositories. In this blog post we show you how to compile it on Windows.

Introduction

Doing a build on Windows is a totally different matter and most users never need to do that. It’s mostly intersting for those wanting own functionality or just being curious. But you should be an experienced Visual Studio user. It’s a complicated task and not a good start for a beginner. The key problem when building on Windows is that we cannot ship any 3rd party library we used. Instead you have to collect them all yourself. In order to ease that task we created the list below. Each library comes with a version number which usually specifies the minimum version to be used. Most of the time it’s not mandatory to use the exact same version, but it helps minimizing trouble if you do. To build and link you need the library’s header files, a dynamic library (.DLL) and the linker library (.lib). There are a few libraries that are static and you may have to build some on your own. You’ve been warned.

After you have downloaded the MySQL Workbench source zip you have to unzip it into a work folder of your choice and name it e.g. “workbench”. In the same work folder where you extracted the source files, create another folder named “mysql-win-res”. This name is mandatory as that is what we used in the VS solution. The build requires a specific folder structure for mysql-win-res (also because of the paths set in the Visual Studio solution). Here’s a picture showing the required folder structure:

Picture 1

All 4 top level dirs are needed. What to put there is mentioned in detail below. Also have a look at the PrepareOutputDir.cmd file in the WB source folder. This is called by VS on successfull build of the main project and copies a lot of dependency stuff to the target folder (under “bin/x64/release”). This batch file will help you to find missing resources if you have trouble starting MySQL Workbench.

Build Preparations

The MySQL Workbench solution (iworkbench/MySQLWorkbench.sln) contains several build targets and architectures. In this blog we only focus on the 64bit release build. After you opened MySqlWorkbench.sln solution you have to set the configuration and platform in Visual Studio. You can do this using the combo box on the standard toolbar (Picture 2) or using Configuration Manager (Menu->Build->Configuration Manager, Picture 3).

Picture 2Picture 3

Now it is time to fill the mysql-win-res folder with all dependencies. You should be able find precompiled binaries for most of them on the Internet. If not then it’s up to you to create it.

Depedencies needed for compiling and starting Workbench

  • boost v1.55.0
    •  download boost from http://www.boost.org
    • copy everything from boost include folder into your mysql-win-res/include/boost folder
  • python v2.7.6
    • download python from (https://docs.python.org/devguide/setup.html#setup)
    • copy header files from python-2.7.6/include into mysql-win-res/iinclude/python folder
    • copy everything form from python-2.7.6/lib into mysql-win-res/lib/python folder
    • place python27.lib and python27.dll into mysql-win-res/lib/x64/python/release
    • place python.exe into mysql-win-res/redist-bin/x64/release
  • cairo v1.8.8
    • download from http://cairographics.org
    • copy header files from cairo-1.8.8/src into mysql-win-res/iinclude/cairo folder
    • place libcairo.lib and libcairo.dll into mysql-win-res/lib/x64/cairo
  • Connector/C++ v1.1.4
    • download zip archive from https://dev.mysql.com/downloads/connector/cpp/
    • extrac and copy header files from mysql-connector/include foolder into mysql-win-res/include/cppcon
    • place mysqlcppconn.lib and mysqlcppconn.dll into mysql-win-res/lib/x64/mysqlcppconn/release
  • CTemplate v0.8
    • download and compile from  http://code.google.com/p/google-ctemplate/
    • copy header files from ctemplate/windows/ctemplate into mysql-win-res/include/ctemplate folder
    • place libctemplate.lib and libctemplate.dll into mysql-win-res/lib/x64/ctemplate/release
  • Geospatial Data Abstraction Library/OpenGIS Simple Features Reference Implementation, v1.9.2
    • download win package from http://www.gdal.org/
    • copy header files  from gdal/core, gdal/ogr, gdal/port, gdal/alg into mysql-win-res/iinclude/gdal folder
    • place bin/gdal.dll and bin/gdal.lib and into mysql-win-res/lib/x64/gdal
    • place gdal/apps/ogrinfo.exe and gdal/apps/ogr2ogr.exe into mysql-win-res/lib/x64/gdal
  • GLib v2.34.3
    • download from http://www.gtk.org
    • copy header files into mysql-win-res/include/glib folder
    • place dll and lib’s into mysql-win-res/lib/x64/glib
  • zlib/libpng v1.5.14
    • download from http://sourceforge.net/projects/libpng
    • copy header files from libpng root folder into mysql-win-res/include/libpng folder
    •  place libpng.dll and libpng.lib into mysql-win-res/lib/x64/libpng
  • Libxml2 v2.9.1
    • download from http://xmlsoft.org
    • copy header files from libxml/include/libxml into mysql-win-res/include/libxml folder
    • place libxml2.dll and libxml2.lib into mysql-win-res/lib/x64/libxml
  • Libconv v1.14
    • download from http://gnu.org/software/libiconv
    • copy header files from libiconv-1.14/include into mysql-win-res/include/libxml folder
    • place libiconv.dll and libiconv.lib into mysql-win-res/lib/x64/libxml
  • Libzip v0.11.2
    • download from http://www.nih.at/libzip
    • copy header files from libzip/lib into mysql-win-res/include/libzip folder
    • place libzip.dll and libzip.lib into mysql-win-res/lib/x64/libzip/release
  • Connector/C v6.1
    • download connector C from http://dev.mysql.com/downloads/connector/c/
    • copy header files from mysql-connector-c/include into mysql-win-res/include/mysql folder
    • place libmysql.dll and libmysql.lib into mysql-win-res/lib/x64/mysql/release
  • PCRE (Perl Compatible Regular Expressions) Library v7.5
    • download package from http://www.pcre.org/
    • copy header filesfrom pcre-7.5 root folder into mysql-win-res/include/pcre folder
    • place pcre.dll and pcre.lib into mysql-win-res/lib/pcre/release
  • Scintilla v3.3.6
  • SQLite v3.8.3
    • download package from http://sqlite.org/
    • copy header file sqlite3.h into mysql-win-res/include/sqlite folder
    • place static sqlite3.dll and sqlite3.lib into mysql-win-res/lib/x64/sqlite/release
  • TinyXML v2.6.1
  • vsqlite++ v0.2.0
    • download package from http://sourceforge.net/projects/sqlitepp/
    • copy header files from vsqlite++-0.2.0/include into mysql-win-res/Include/vsqlite++/sqlite folder
    • place static vsqlite++.lib into mysql-win-res/lib/x64/vsqlite++/sqlite
  •  zlib v1.2.5
    • download and compile from  http://www.zlib.net/
    • copy header files from zlib-1.2.5 root folder into mysql-win-res/include/zlib folder
    • place zlib.dll and zlib.lib into mysql-win-res/lib/x64/zlib/release
  • ANTLR v3.4
    • download antlr-3.4 from http://www.antlr3.org
    • create bin folder under mysql-win-res and copy antlr-3.4-complete.jar into
  • SWIG (version 3.0.2)
    • download swigwin.zip package from http://www.swig.org
    • create folder swiglib under mysql-win-res
    • extrac swig archive and copy everyting from swigwin-3.0.2/lib folder into created mysql-win-res/swiglib folder
    • place swig.exe into early created mysql-win-res/bin folder
  • MySQL Server executables
    • place mysqldump.exe and mysql.exe into mysql-win-res/redist-bin/x64/release. You can find this file in your local MySql server instalation under bin directory

Once this setup is done you can start the build in Visual Studio.

I hope this helps to get your application compile on Windows and if you have any questions you can contact the Workbench team on the #workbench IRC channel.