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 Launchpad.net which is tightly integrated with Bazaar. Launchpad.net is kind of like SourceForge.net, 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 Launchpad.net at http://launchpad.net/drizzle.

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.

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.

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 Launchpad.net 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:

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.

Jay, thanks for the post it helped a lot. ( I was present during the drizzle dev day in santa clara, struggling to get the dev up in my mac) Did you left out the obvious 'sudo make install' ? Also in the wiki (http://drizzle.org/wiki/Compiling) , it is told to do configure-make step in libdrizzle dir is that same as doing it outside ?

http://joinfu.com jaypipes

Hi!

If you’re working in a source directory, you shouldn’t be doing sudo make install. For libdrizzle, you can either sudo apt-get install libdrizzle-dev, or build and sudo make install a source directory of libdrizzle. Does this answer your question? Lemme know if it doesn’t!

Cheers,

jay

http://joinfu.com/ Jay Pipes

Hi!

If you're working in a source directory, you shouldn't be doing sudo make install. For libdrizzle, you can either sudo apt-get install libdrizzle-dev, or build and sudo make install a source directory of libdrizzle. Does this answer your question? Lemme know if it doesn't!

Cheers,

jay

http://experiencesoftheordinary.blogspot.com ivotron

Hi Jay,

I tried the hard way today and ./configure additionally required for gperf, libdrizzle-dev and libboost-program-options-dev

Thanks!

http://joinfu.com/ Jay Pipes

Hi Ivo!

Thanks for the heads up. Updated the article

Cheers!jay

http://joinfu.com/ Jay Pipes

Hi Ivo!

Thanks for the heads up. Updated the article

Cheers!
jay

http://www.louisvuittonbagmall.com/ louis

replace apt-add-repository with add-apt-repository (a typo)!

Anurag Priyam

On a Debian system you can just say ‘sudo aptitude build-dep drizzle’ to get all the packages required for developing drizzle.

http://joinfu.com/ Jay Pipes

Yep, that’s true. Note that this article was written >2 years ago. Back then, things weren’t quite as simple

aj

after getting Drizzle for bzr and compiling it.. whats the next approach to fix bugs… how do i find the bugs basically

http://joinfu.com/ Jay Pipes

I would hop over to #drizzle on IRC (freenode.net) and ask krow and others what bugs are good ones to start with.