The 5.7.5 DMR is now available, and we’ve made some changes to our build system in this one, so I wanted to spend some time discussing how you would now build MySQL.
When we released our April labs release, I wrote about building MySQL with Boost. Now that the first GIS work using Boost.Geometry has passed all the hurdles and landed in a development milestone release (DMR), it’s time to revisit the topic. From now on (5.7.5 and newer), MySQL needs Boost headers to compile. It’s not optional.
We got a few bug reports on the build process for the labs release. Hartmut Holzgraefe quickly submitted bugs 72172, 72185, 72186 and 72188, which have all now been fixed. Thank you, Hartmut! It’s very encouraging for all of us working on this to get quality feedback on a labs release!
Getting Started
Assuming that you’ve just downloaded the 5.7.5 tarball:
1 2 3 4 5 6 |
tar zxf mysql-5.7.5.tar.gz cd mysql-5.7.5 mkdir bld cd bld cmake .. -DDOWNLOAD_BOOST=1 -DWITH_BOOST=~/my_boost make |
This is almost exactly the same way we did it in the labs release. Actually, that CMake command line way still works, I’ve only changed $HOME to ~ to demonstrate that it now works. We now also support relative paths (bug 72185).
We’ve also improved the error messages if anything goes wrong (bug 72172).
This is the recommended way for developers to build MySQL. If you already have the correct Boost version installed in your include path (we only need the header files), you don’t need any CMake options at all.
After the first build, you can drop the build options on later CMake runs. CMake will remember your settings. However, it doesn’t hurt to always use them.
Advanced Build Options
There are two new build options: WITH_BOOST
and DOWNLOAD_BOOST
. I’ll describe both here, but if you really want to look at all the details and inner workings, have a look at cmake/boost.cmake
in the source tree.
WITH_BOOST
This specifies where CMake will find Boost. It can point to:
- a tarball/zip file
- a directory containing a tarball/zip file (it has to have the standard Boost tarball/zip file name)
- a directory where the tarball/zip file was unpacked
You can specify both absolute and relative paths, and the tilde will be expanded. And of course, any path name expansion your shell does for you will work. There’s no default value. If you don’t specify anything, you’ll need to have Boost in you normal include path.
The WITH_BOOST
build option can be set on the CMake command line like in the example above, or you can use the WITH_BOOST
environment variable. Our CMake scripts will also recognize the BOOST_ROOT
environment variable that is commonly used by projects using Boost as an alias for WITH_BOOST
.
The order of precedence is (highest to lowest):
WITH_BOOST
option on the CMake command lineWITH_BOOST
environment variableBOOST_ROOT
environment variable
If CMake can’t find Boost, it will fail with a friendly error message telling you how to use DOWNLOAD_BOOST
.
DOWNLOAD_BOOST
This boolean option tells CMake to download the Boost tarball or zip file from Boost’s standard download location (currently Sourceforge). The default is DOWNLOAD_BOOST=0, which means don’t download. Set it to 1 to enable downloading.
In order to provide a stable code base, MySQL depends on a specific version of Boost. When we change our code to depend on a newer version of Boost, DOWNLOAD_BOOST=1
will make sure the new version will be automatically downloaded for you.