Thrift is a efficient framework for cross-language serialization and RPC that recently became an Apache Incubator project. It’s definately a cool project to check out if you are building a high traffic web application or are writing distributed computing code. Installing the framework on OS X isn’t currently totally straightforward, provided below is a guide to get Thrift built on OS X Leopard.
First, gather required sources – Thrift depends on the Boost and libevent libraries, grab the latest revisions of each and then download the latest Thrift snapshot.
Build Boost first:
cd [boost root] ./configure sudo make install
This takes a while, go make a cup of coffee – and when it finishes build libevent, which takes much less time:
cd [libevent root] ./configure make sudo make install
At this point is where most Thrift builds will run into trouble, as the pkg.m4 file required by autoconf in upcoming steps does not get correctly found.The following error will be encountered when trying to configure the package:
./configure: line 21183: syntax error near unexpected token `MONO,' ./configure: line 21183: ` PKG_CHECK_MODULES(MONO, mono >= 1.2.6, have_mono=yes, have_mono=no)'
The official faq says that in order to get this file, one should install macports, and then use it to install pkg-config – but as macports is a colossal pain in the ass, we’ll do something else. The pkg.m4 file is also installed when X11 is installed off the OS install disc, and since X11 is something you can’t live without if you’re working on or with mainstream open source software, that is the route we will take. After installing X11 (not shown here, because it just consists of running the installer package on the OS X disc), do the following to get pkg.m4 where it needs to be:
cd [thrift root] cp /usr/X11/share/aclocal/pkg.m4 aclocal/
After doing this, Thrift can build without issues, which will take some time, but not nearly as long as Boost did:
./bootstrap.sh ./configure make sudo make install
Hope this helps anyone trying to write Thrift code on OS X!
[...] a recent post, I explained how to install the Thrift RPC framework on OS X 10.5. Another scenario that doesn’t install as advertised out of the box is building Thrift on [...]
Thanks man, this really helped!
Have you tried running thrudb on 10.5 leopard as well?
Cheers
Have not tried thrudb on OS X yet, but probably will soon as I’m doing a lot of work currently with Lucene and am interested in thrudex.
Have you done any work with thrudb on OS X?
[...] the Mac you can use the MacPorts to install the required packages.. Max also had a good page on Installing Apache Thrift on Mac OS X 10.5 Leopard that doesn’t require [...]
I’ve spent a lot of time getting things to compile smoothly on osx. let me know if you have any issues.
Jake, your project looks really interesting! Thanks for taking the time to comment, I’m looking forward to having a chance to play with thrudb this weekend!
I had an additional problem with the current code as of April 22, 2009. When building the java module, the build fails because it can’t find a copy of log4j.jar. This is the fix:
Create ~/.thrift-build.properties and use it to point to a log4j jar somewhere on your system:
thrift.extra.cpath=/tmp/log4j-1.2.15.jar
There is an open issue about this you can track:
http://issues.apache.org/jira/browse/THRIFT-453
Thanks for posting that! I’m going to try and replicate that tonight – I’ll add your workaround after I check it out myself.
Thank you very much for posting this. It works like a charm. It would have taken me ages to solve this by myself.
On my Mac, the thrift install hung during make at
(dix) enabling device 0
(dix) enabling device 1
(dix) enabling device 2
(dix) enabling device 3
(dix) enabling device 4
(dix) enabling device 6
AllocNewConnection: client index = 1, socket fd = 9
Somehow the installer then managed to pop up X11, and if I went over to X11 and created a new window, I’d see a new line of
AllocNewConnection: client index = [another number], socket fd = [some other number]
The solution is to SKIP the bootstrap.sh step. If you’ve already run bootstrap.sh, just re-download a fresh copy of thrift.