Not counting obtaining the source code, and once you have the prerequisites satisfied, [Windows] users can build from source code in 5 easy steps.
Prerequisites – Install & ensure they are in the $PATH:
- CMake <-- Download
- C++ compiler <-- Visual Studio 2008 Express - Free Download
- Bison <-- Download (ensure m4.exe is also included, which it should be)
Optional (but most likely you’ll want):
- Perl <-- For Test Suite/Scripts. Strawberry Perl is a great option.
- Bazaar <-- If want latest source tree
Tip: Install these in locations where spaces are not in the path. Specifically, watch for the Bison/m4 as there is a known bug with regards to that.
Now that that’s out of the way, we can begin. You just need to decide if you want to build from source code you download or from the latest development tree.
This will walk through building from the latest development tree (since the downloaded version requires no extra steps – just grab it from any mirror).
Also, this post assumes you can connect to the Launchpad repository via Bazaar and download the source (i.e., you’ll have to create SSH keys to connect to Launchpad – see this write-up for more details. You might also need Pageant too, if you don’t already have it.)
I. Prerequisite Checks:
C:\>cmake --version cmake version 2.6-patch 4 C:\>bison --version bison (GNU Bison) 2.4.1 C:\>m4 --version m4 (GNU M4) 1.4.13 C:\>perl --version This is perl 5, version 12, subversion 3 C:\>bzr --version Bazaar (bzr) 2.4.1
II. Obtain Source Code (skip this if you download the source directly from a mirror):
- Open Pageant -> Add Key -> Select your SSH Key (for Launchpad)
- cd C:\
- bzr init-repo –trees mysql-5.5
- cd mysql-5.5
- bzr branch lp:mysql-server/5.5 mysql-5.5
III. Build/Compile Source Code:
- cd mysql-5.5
- cmake . -DBUILD_CONFIG=mysql_release -G “Visual Studio 9 2008”
- Copy m4.exe to $basedir/sql <-- this avoids any m4.exe errors (or fix this permanently if this affects you)
- Open Solution in VS: File -> Open -> Project/Solution -> C:\mysql-5.5\mysql-5.5\MySQL.sln
- Now build in VS: Build -> Build Solution (or F7)
========== Build: 93 succeeded, 0 failed, 5 up-to-date, 10 skipped ==========
There you have it! (Assuming you have “0 failed”, otherwise, you’ve got some debugging to do.)
For those interested, I have full outputs, and common errors (with their solutions) from the entire process here:
Build Notes (step #2 above):
The -DBUILD_CONFIG=mysql_release flag uses the same build options used for official releases, which are stored in cmake/build_configurations/mysql_release.cmake.
The simplest you could use is: cmake . -G “Visual Studio 9 2008”
Or you could specify a number of options: cmake . -DMYSQL_SERVER_SUFFIX=-chris -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 -DWITHOUT_BLACKHOLE_STORAGE_ENGINE=1 -G “Visual Studio 9 2008”
The -G lets know which compiler will be used. In this case, I’m using VS 2008 Express. If you were using VS 2005, it’d be “Visual Studio 8 2005”, but I’m not sure if VS 2005 will even work.
This command should end with something like “– Build files have been written to: C:/…” or you’ll need to debug.
Lastly, the cmake command creates the MySQL.sln file and all .vcproj files.
IV. Kicking the tires …
Creating a “package” in Visual Studio is quite simple:
In the “Solution Explorer” view (far right-hand side of page), right-click on “PACKAGE” -> then “Build”.
If you have problems with this, it can be pieced together easily enough:
- Make main dir mysql-5.5.xx
- Make subdir bin/ – copy in all .exe files (from client/debug, sql/debug, */debug, etc.)*
- Make subdir data/ – copy from sql/data/
- Make subdir scripts/ – copy from scripts/ (at least all perl, sql, and sh scripts)
- Make subdir share/ – copy from sql/share/
- Create my.ini
* Notes re: .exe files: mysqld.exe is located in /sql/debug/ and mysql.exe is located in /client/debug/. The remaining .exe files are located in /client/debug/, /sql/debug/, /extra/debug/, /libmysql/debug/, /mysys/debug/, /scripts/debug/, /storage/myisam/debug/, /storage/heap/debug/, and /tests/debug/.
Now start mysqld:
mysql> select version(); +------------------+ | version() | +------------------+ | 5.5.21-debug-log | +------------------+
Of course you should test it a bit more than that, but I’ll leave that to you.
Related Build Links:
- Building MySQL and MariaDB on Windows using Visual Studio 2012 Express versus Visual Studio 2010 Express:
- How to Build MySQL 5.7 on Windows from Source Code:
- How to Build MySQL 5.6 on Windows from Source Code:
- How to Build MySQL 5.5 on Windows from Source Code:
- How to Build MariaDB 10.0 on Windows from Source Code:
- How to Build MariaDB 5.5 on Windows from Source Code:
- Building MariaDB 5.3 on Windows:
- Building MariaDB 5.1 on Windows:
- Building MariaDB 5.1 on Windows Revisited:
- Troubleshooting Building MariaDB 5.1 on Windows:
- MySQL 5.5 Windows Build Appendix : Full Outputs and Common Errors from Building MySQL 5.5 on Windows:
- Maintaining (and Building) your MySQL Source Tree on Windows:
- Resolving the bison.exe m4 Invalid argument Error when building MySQL/MariaDB/XtraDB on Windows:
- Resolving sasl/sasl.h Not Found during CMake when Building MySQL on Windows:
- Resolving Missing ‘sys’ Include Files: devpoll.h, epoll.h, event.h, and queue.h during CMake when Building MySQL on Windows:
- Building XtraDB on Windows: