Gitting the latest source
For instance they show you how to get the latest via SVN or a snapshop via wget. But the wget actually gets it from a git repository, but they don’t tell you how to directly git it! Which is:
git clone git://git.thrift-rpc.org/thrift.git
That will create a a source distribution of thrift in a directory called thrift.
The relevant requirements as stated by the wiki are:
GNU build tools: autoconf 2.59+ (2.60+ recommended), automake 1.9+, libtool 1.5.24+
pkgconfig (Use MacPorts for Mac OS X)
lex and yacc (developed primarily with flex and bison)
Well, for Ubuntu it wasn’t quite clear what was really required. The GettingUbuntuPackages wiki page listed only a few of the required packages. Max Luebbe has a blog page that has a more in depth list:
apt-get install libboost-dev libevent-dev python-dev automake pkg-config libtool flex bison sun-java5-jdk
We already had Sun Java6 installed and that worked fine, so I didn’t include sun-java5-jdk. But we didn’t have g++ installed, so also do:
apt-get install g++
Confusingly, the ./configure did not fail saying there was no g++ but failed by saying there was no boost. It took a while to figure out it was actually not finding boost because it could not compile the little configure test script that was used to detect if boost was installed or not!
So the actual apt-get used on our ubuntu 8.04 server was:
sudo apt-get install g++ libboost-dev libevent-dev python-dev automake pkg-config libtool flex bison
On 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 MacPorts.
sudo port selfupdate sudo port install boost sudo port install pkgconfig
The pkg.m4 workaround
As noted in the Thrift Wiki FAQ,the ./configure command may generate an error like:
./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)'
This will happen if there is no pkg.m4 file in the aclocal directory of the thrift source tree. For the Macintosh, install pkgconfig via MacPorts and copy /opt/local/share/aclocal to aclocal (assuming you are in the thrift source distro):
cp /opt/local/share/aclocal/pkg.m4 aclocal
This is not necessary in ubuntu if you have installed pkgconfig there.
Actual Build and Installation
In the Thrift directory run:
on the Mac if boost was installed with MacPorts use the following (If you manually installed boost elsewhere use that path instead):
on Ubunto you can just say”
On both Mac and Ubuntu:
make sudo make install
If you want any of the bindings for different languages, cd into lib and there are directories for each language. Its not always clear what to do to build them. For the ruby one what I ended up doing was:
cd lib/rb sudo ruby setup.rb
Figure out how to test and use Thrift!