Getting Thrift up and running

There are a couple of neat projects out that offer lightweight binary formats for sending messages across the wire, namely Protocol Buffers (Google) and Thrift (Facebook). Both options give you an extensible mechanism for defining messages and encoding/decoding them in just about any useful programming language.

I’ve been evaluating Thrift as well as Protocol Buffers and found out that even though Thrift is very feature rich, it lacks sorely in documentation. In fact their documentation goes something like:

How to bake a cake
Step 1: Bake the cake.

So I thought I would talk about my experiences getting it running. This tutorial isn’t extremely useful for someone wanting to learn how to build applications on top of Thrift, but it should at least get the sample code running for you.

Disclaimer: I’m running a Intel Macbook with OSX 10.5.5, if your system is different your experience my differ.

First your going to need Boost. Unless your planning on using C++ it’s just going to use for Thrifts IDL compiler so if you installing some C++ libraries has you wondering what you’ve got yourself into, don’t worry once it’s done you can probably forget about it.

Just grab Boost from Sourceforge, build and install it.

curl -o boost_1_37_0.tar.gz \
tar xzvf boost_1_37_0.tar.gz
cd boost_1_37_0
sudo make install

Now we can grab the Thrift code.

  curl -o thrift.tgz \
  tar xzvf thrift.tgz
 cd thrift

Next, Thrift comes with a bootstrap script that you need to run before configuring it.


So the next step should be to configure Thrift.


But this breaks with the following error:

./configure: line 20743: syntax error near unexpected token `MONO,'
./configure: line 20743: `  PKG_CHECK_MODULES(MONO, mono >= 1.2.6, have_mono=yes, have_mono=no)'

I tried compiling without without csharp support, but it still didn’t work so I did some hacking on the configure script. If you want C#/Mono support this hack won’t work for you, but I didn’t so I commented out the line above that says PG_CHECK… and added the following line below it (this is a hack not a real solution):


Now you should be able to continue:

sudo make install

Yay, now you have Thrift installed.