Building MySQL with Boost

We have a new April labs release that you can download from There are more labs releases. Please try them all, but for now let’s focus on the one called “MySQL GIS, InnoDB R-tree, Parser Refactoring”.

The release contains InnoDB R-trees, the first step of our new GIS implementation, a refactored and faster parser and improved condition filtering cost calculations. You can download and run the binaries just like before, but if you want to build it from source, there are some details you should know. Otherwise you may fail to build MySQL (bug #72172).

This labs release requires Boost to build. Specifically, it requires Boost 1.55. But don’t go running off to looking for the latest tarball just yet — there’s no need for that. The MySQL build system will do everything for you.

The easy way

Assuming that you’ve just downloaded the tarball:

tar zxf mysql-5.7.4-labs-april.tar.gz
cd mysql-5.7.4-labs-april
mkdir bld
cd bld

This is the way we expect most developers to build MySQL. The CMake script will look for Boost in ~/my_boost. If it’s not there, it will download and unpack it (in that directory) for you.

Don’t remove the -DDOWNLOAD_BOOST=1 flag the next time you build. The build script is smart enough to recognize that you’ve already downloaded Boost and won’t do it again. However, when we change our dependency to Boost 1.56, it will download that version automatically.

That’s all there is to it. Don’t be an April fool, build the April labs release the easy way!

Other ways to build

There are other ways to do it. You can download and unpack the Boost tarball or zip yourself, or download it and let CMake unpack it. Just point your WITH_BOOST to the file, the directory containing the file, or the directory where you unpacked it. The CMake script will handle the rest.

If you get tired of writing -DWITH_BOOST=$HOME/my_boost on the command line, you can set an environment variable. The build script will understand both the commonly used BOOST_ROOT and our own WITH_BOOST.

There’s one gotcha: You may have noticed that I write $HOME instead of ~. This is because the CMake script doesn’t do tilde expansion when you specify WITH_BOOST on the command line. If you use an environment variable instead, use whatever you like.

The even easier way?

If you happen to already have Boost 1.55 installed in /usr/include or some other location where the compiler will pick it up, you can build MySQL without specifying the location of Boost. This is the way we expect Linux distros to compile MySQL. If the correct Boost version is part of the distro, just list it as a build dependency and everything will work out of the box.

This sure looks even easier than what I described above, but the build will fail if you don’t switch Boost versions at the same time as we do. So if you’re a developer and choose to build it this way, it may look easier to begin with, but you’ll have to do more work when we upgrade Boost.

That said, we don’t plan to upgrade Boost very often. We should really stay put on one Boost version throughout the whole 5.7 series, so we have made sure we can patch for bugs without upgrading. If you look inside the source tarball, you will see that there are a few bug fixes in there already. They have been committed upstream, and we can remove the fixes from our tree when Boost 1.56 is released and we upgrade our dependency.

Look ma, no runtime dependencies

That’s right, we only use the Boost header files. We started using Boost because of GIS, and so far it’s the only thing we use it for. Boost.Geometry is a headers-only library, so there are no extra libraries to load at runtime.

Beacause of Boost, we also switched compilers from Sun Studio to GCC on Solaris. That adds some runtime dependencies for the server on Solaris, but please note that this is only the server. The client library is still compiled with Sun Studio, so there are no extra dependencies for client applications.

Feedback wanted

This is a labs release, so please test it and give us feedback. Do you like this development? Any questions or opinions? Are you missing a build option to make your life with Boost easier? Tell us! It’s much better for all if we get these things right from the start instead of realizing later on that we should have done it differently.

Use the comment field below! It’s there for a reason. :-)

About Norvald H. Ryeng

Norvald H. Ryeng has been working as a software engineer on the MySQL Optimizer Team since 2011. He is also the point of contact for package maintainers in Linux distributions. He holds a PhD in Computer Science from the Norwegian University of Science and Technology.

8 thoughts on “Building MySQL with Boost

  1. Also make sure that WITH_BOOST is an absolute path ( ),
    and if you decide to move the boost folder to a different palce it is not sufficient to re-run CMake with a different -DWITH_BOOST setting, you also need to override the cached LOCAL_BOOST_ZIP as otherwise it will continue to contain the old path to the downloaded boost tarball ( )

Leave a Reply

Your email address will not be published. Required fields are marked *