Articles, C/C++, Drizzle, MySQL

Getting a Working C/C++ Development Environment for Developing Drizzle

This article explains how to set up a properly functioning C/C++ development environment on Linux. The article is aimed at developers interested in contributing to the Drizzle server project, but the vast majority of the content applies equally well to developers wishing to contribute to the MySQL server or any other open source project written in C/C++

IMPORTANT: This article doesn’t get into any religious battles over IDEs or particular editors. IDEs and editors are what you use to edit code. What this article covers is the surrounding libraries, toolchain, and dependencies needed to get into the development or contirbution process. That said, go Vim. ๐Ÿ˜‰

The examples shown use the Debian/Ubuntu methods of obtaining code packages and installing them รขโ‚ฌโ€ specifically, using apt-get install to install packages. If you are running on a RPM-based distro, simply change the commands to use your package manager of preference, for instance yum install. Solaris users should get as far as they can in the installation/setup process and hop over to the Freenode #drizzle channel for help from one of Solaris experts. The Drizzle wiki has more information on specific packages needed for different distributions.

OK, let’s get started, shall we?

Installing Bazaar and Some Bzr Goodies

So, what is this Bazaar thing and why do you need it? Good question! Bazaar is the revision control system that the Drizzle development team (as well as the MySQL engineering team) uses for source code control. The good folks over at Canonical maintain and enhance the excellent Bazaar-NG system and have an online platform called which is tightly integrated with Bazaar. is kind of like, only focused around Bazaar as the revision control system, and includes a number of nifty little features that make it easier to manage and maintain teams of developers working on the code base. The Drizzle Server project is hosted on at

To install Bazaar, issue the following:

sudo apt-get install bzr

Some Optional Goodies

Once installed, you might want to install a few more things that will make your bzr life easier. The bzrtools package is a collection of command-line and graphical utilities for bzr. meld is a graphical merge conflict resolution utility that I have found invaluable at times. PoEdit is an easy way to work with the GetText translation utilities. To install these tools, do:

sudo apt-get install bzrtools meld poedit

OK, that’s it for Bazaar for now. Let’s move on to getting your development toolchain installed.

The Required Toolchain Packages and Library Dependencies

In order to compile the Drizzle server, you will need a working GNU Toolchain with the C++ development tools.

The Easy Way

The best and most consistent way to get these build dependencies if you are working on Debian/Ubuntu, is to add the Drizzle Developers Personal Package Archive to your apt path and install the Drizzle dependencies.

This way to do this via the terminal:

# For Ubuntu >= 9.10 (Karmic):
sudo add-apt-repository ppa:drizzle-developers/ppa
sudo apt-get update
sudo apt-get install drizzle-dev

For versions of Ubuntu prior to 9.10, simply head over to the Drizzle Developers PPA and follow the instructions on that page.

The Hard Way

The following packages are required for building Drizzle.

  • binutils (includes ld and as)
  • gcc/g++ (4.2+)
  • autoconf (2.59+)
  • automake (1.10+)
  • libtool (1.5.24+)
  • m4 (1.4.8+)
  • bison/yacc (2.3)
  • pkg-config (0.22+)

To install the above toolchain, do the following:

sudo apt-get install libc-dev gcc g++ bison binutils automake autoconf m4 pkg-config libtool
NOTE: Thanks to Tom Hanlon…older versions of Ubuntu may need to specify libc6-dev, not libc-dev!

Once apt-get finishes installing the above, you’ll have a system capable of compiling C/C++ programs, for the most part. The Drizzle server needs some additional libraries and header files in order to compile. I list them here along with a brief description of the library or file.

  • libpcre3 – A standard PCRE regular expression library
  • libpam0g – A pluggable authentication modules library (a horrible package name, no?…)
  • libncurses – A library for displays of terminal applications (used by the drizzle client)
  • libprotobufGoogle Proto Buffers library, used by the server in message communication
  • gettext – i10n and l10n services
  • libevent – socket event handling
  • libz – compression
  • libreadline – Command-line editing utilities
  • uuid-dev – UUID headers
  • libboost-dev – BOOST C++ headers and library
  • libboost-program-options-dev – BOOST program_options library headers
  • libdrizzle-dev – libdrizzle headers
  • gperf – GNU hash function generator
  • libgcrypt11-dev – GNU Crypto library

The following command should install the required libraries with the exception of Google Proto Buffers, which is described in the following section.

sudo apt-get install libpcre3-dev libpam0g libncurses5-dev libpam0g-dev gettext libevent-dev libz-dev libreadline-dev uuid-dev  libgcrypt11-dev libboost-dev libboost-program-options-dev libdrizzle-dev gperf

Installing Google Proto Buffers

After installing the libraries and toolchain, you’ll need to install the Google Proto Buffers library. Again, the easiest way to do so is via the Drizzle Developers PPA, which you should have added to your repositories above. If you did, simply do:

sudo apt-get install libprotobuf-dev protobuf-compiler

Setting Up a Local Bazaar Repository for Drizzle

Now that you’ve installed all the required toolchain and dependencies, it’s time to use Bazaar to pull the development branch of Drizzle and compile the Drizzle server. The first step to do is to set up that local bzr repository. Myself, I have all my bzr repositories in a directory called ~/repos, and that is what the below examples show, but you are of course welcome to put your repos wherever you prefer. To set up a directory and a drizzle repo under your home directory, do the following:

cd ~
mkdir repos
cd repos
bzr init-repo drizzle
cd drizzle

At this point, you have a local bzr repository. Let’s now create a local branch of the development source code trunk that we can play with. To do so, we use the bzr branch command, like so:

bzr branch lp:drizzle trunk

This tells bzr to go grab the main development branch of the “drizzle” project that resides on the servers (thus, the lp: prefix), and create a local branch called “trunk”. The branch operation may take a little while to complete when you do it for the first time. Subsequent branch and merge operations are much, much quicker than the first branch into a repository. When the branch succeeds, go ahead and look at the files that have been downloaded into your “trunk” branch:

cd trunk
ls -la

You should see something like the following:

jpipes@serialcoder:~/repos/drizzle/trunk$ ls -la
total 264
drwxr-xr-x 13 jpipes jpipes  4096 2010-02-25 12:39 .
drwxr-xr-x 16 jpipes jpipes  4096 2010-03-10 19:44 ..
-rw-r--r--  1 jpipes jpipes 76502 2010-02-24 23:30 ABOUT-NLS
-rw-r--r--  1 jpipes jpipes   377 2010-02-24 23:30 AUTHORS
drwxr-xr-x  5 jpipes jpipes  4096 2010-02-24 23:30 .bzr
-rw-r--r--  1 jpipes jpipes  5983 2010-02-25 12:39 .bzrignore
drwxr-xr-x  2 jpipes jpipes  4096 2010-03-10 15:27 client
drwxr-xr-x  2 jpipes jpipes  4096 2010-02-24 23:30 config
-rw-r--r--  1 jpipes jpipes  5350 2010-02-24 23:30
-rw-r--r--  1 jpipes jpipes 19071 2010-02-24 23:30 COPYING
-rw-r--r--  1 jpipes jpipes 56574 2010-02-24 23:30 Doxyfile
drwxr-xr-x 16 jpipes jpipes 12288 2010-03-10 15:27 drizzled
-rw-r--r--  1 jpipes jpipes  5962 2010-02-24 23:30 DRIZZLE.FAQ
-rw-r--r--  1 jpipes jpipes  5139 2010-02-24 23:30 EXCEPTIONS-CLIENT
drwxr-xr-x  2 jpipes jpipes  4096 2010-02-24 23:30 extra
drwxr-xr-x  2 jpipes jpipes  4096 2010-02-24 23:30 gnulib
drwxr-xr-x  2 jpipes jpipes  4096 2010-02-24 23:30 m4
-rw-r--r--  1 jpipes jpipes  4545 2010-02-24 23:30
-rw-r--r--  1 jpipes jpipes    41 2010-02-24 23:30 NEWS
drwxr-xr-x 55 jpipes jpipes  4096 2010-03-05 13:11 plugin
drwxr-xr-x  2 jpipes jpipes  4096 2010-02-24 23:30 po
-rw-r--r--  1 jpipes jpipes   821 2010-02-24 23:30 README
drwxr-xr-x  3 jpipes jpipes  4096 2010-02-24 23:30 support-files
drwxr-xr-x  8 jpipes jpipes  4096 2010-03-10 15:27 tests

Compiling Drizzle

OK, you are now ready to compile the server and client tools contained in your branch. The way to do so is the following:

./configure --with-debug
make test

If all goes well, drizzle will compile and build, get installed, and output the (hopefully!) passing test results. The output at the end should be similar to the following:

collation_dictionary.slap      [ pass ]             54
blackhole.blackhole            [ pass ]             13
archive.archive                [ pass ]            509
archive.archive_aio_posix      [ pass ]            487
archive.archive_basic          [ pass ]              2
archive.archive_discover       [ pass ]              2
Stopping All Servers
All 290 tests were successful.
The servers were restarted 36 times
Spent 206.430 of 290 seconds executing testcases

And that’s it. ๐Ÿ™‚

OK, so that’s it for this first article. I hope you’ve found it helpful in getting a development environment set up so that you can feel comfortable contributing to the Drizzle project. Join me on Freenode’s #drizzle IRC channel to get some help. We’re always available.