Press "Enter" to skip to content

Installing Apache Thrift on Ubuntu and Leopard

The instructions for installing the Apache Thrift on the Wiki missed a few key things in terms of installing on Ubuntu (8.04 in my case) and Macintosh OS X Leopard (10.5.6).

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 git repository is where the developers are really working according to the Developers Wiki on the GitRepository. There is also a copy on github.

Requirements

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+
boost 1.34.0+
g++ 3.3.5+
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:

./bootstrap.sh

on the Mac if boost was installed with MacPorts use the following (If you manually installed boost elsewhere use that path instead):

./configure --with-boost=/opt/local

on Ubunto you can just say”

./configure

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

Next step

Figure out how to test and use Thrift!

10 Comments

  1. Max Max March 5, 2009

    Thanks for the link!
    I probably should have mentioned the build-essential package (Installs a bunch of build tools and compilers) on Ubuntu as well, but this slipped my mind because I assumed anyone compiling c++ would have already installed the compilers.
    I’ll go back and add it for the sake of completeness.

    Good post!

  2. adam adam May 5, 2009

    Thank you. Ubuntu/Thrift/Boost installation = PITA. I’m only out a couple of hours trying to build from scratch. Found your post. Minutes later I’m moving on to the next step: “Figure out how to test and use Thrift!” (WTF is boost, anyway?)

  3. nm nm March 2, 2010

    I don’t suppose you have found a site somewhere that has packaged Thrift as a Ubuntu package?

    • Robert J Berger Robert J Berger March 2, 2010

      I haven’t looked into this for a while. We aren’t using the Thrift interface at this point. We may use it again at some other time.

  4. Alex Boisvert Alex Boisvert May 1, 2010

    Just another thank you for your instructions. Saved me from tons of hassle 🙂

  5. Francois K6 Francois K6 September 3, 2010

    Hi all,
    after executing “make” i got this:

    [FAILURE:/home/francois/Downloads/Development/thrift/thrift/test/ThriftTest.thrift:31] No generator named ‘*’ could be found!
    make[4]: *** [gen-cpp/ThriftTest_types.cpp] Error 1
    make[4]: Leaving directory `/home/francois/Downloads/Development/thrift/thrift/lib/cpp/test’
    make[3]: *** [all-recursive] Error 1
    make[3]: Leaving directory `/home/francois/Downloads/Development/thrift/thrift/lib/cpp’
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/home/francois/Downloads/Development/thrift/thrift/lib’
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/francois/Downloads/Development/thrift/thrift’
    make: *** [all] Error 2

    any clue on how to solve it?

  6. clear clear January 7, 2011

    Thank you. Finally installed.

  7. Cuong Cuong September 8, 2011

    when i run make command, i got:

    /bin/bash ../../../libtool –tag=CXX –mode=link g++ -Wall -g -O2 -o Benchmark Benchmark.o libtestgencpp.la -lrt -lpthread
    libtool: link: cannot find the library `data/soft/Thrift/thrift-0.6.0/lib/cpp/libthrift.la’ or unhandled argument `data/soft/Thrift/thrift-0.6.0/lib/cpp/libthrift.la’
    make[4]: *** [Benchmark] Error 1
    make[4]: Leaving directory `/home/cuongnlv/Cuong data/soft/Thrift/thrift-0.6.0/lib/cpp/test’
    make[3]: *** [all-recursive] Error 1
    make[3]: Leaving directory `/home/cuongnlv/Cuong data/soft/Thrift/thrift-0.6.0/lib/cpp’
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/home/cuongnlv/Cuong data/soft/Thrift/thrift-0.6.0/lib’
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/cuongnlv/Cuong data/soft/Thrift/thrift-0.6.0′
    make: *** [all] Error 2

  8. Andres Andres October 26, 2011

    Getting the following error:

    ==> jsx (compile)
    ./include/jsx_common.hrl:34: type jsx_opt() undefined
    ./include/jsx_common.hrl:66: type jsx_parser_result() undefined
    ./include/jsx_common.hrl:34: type jsx_opt() undefined
    ./include/jsx_common.hrl:66: type jsx_parser_result() undefined
    ./include/jsx_common.hrl:82: type eep0018_array() undefined
    ./include/jsx_common.hrl:82: type eep0018_array() undefined
    ./include/jsx_common.hrl:82: type eep0018_object() undefined
    ./include/jsx_common.hrl:84: type eep0018_term() undefined
    ./include/jsx_common.hrl:82: type eep0018_object() undefined
    ./include/jsx_common.hrl:85: type eep0018_key() undefined
    ./include/jsx_common.hrl:85: type eep0018_term() undefined
    ./include/jsx_common.hrl:91: type eep0018_string() undefined
    ./include/jsx_common.hrl:84: type eep0018_term() undefined
    ./include/jsx_common.hrl:34: type jsx_opt() undefined
    ./include/jsx_common.hrl:85: type eep0018_key() undefined
    ./include/jsx_common.hrl:92: type eep0018_number() undefined
    ./include/jsx_common.hrl:66: type jsx_parser_result() undefined
    ./include/jsx_common.hrl:85: type eep0018_term() undefined
    ./include/jsx_common.hrl:100: type encoder_opt() undefined
    ./include/jsx_common.hrl:82: type eep0018_array() undefined
    ./include/jsx_common.hrl:91: type eep0018_string() undefined
    ./include/jsx_common.hrl:109: type decoder_opt() undefined
    ./include/jsx_common.hrl:82: type eep0018_object() undefined
    ./include/jsx_common.hrl:92: type eep0018_number() undefined
    ./include/jsx_common.hrl:117: type verify_opt() undefined
    ./include/jsx_common.hrl:84: type eep0018_term() undefined
    ./include/jsx_common.hrl:100: type encoder_opt() undefined
    ./include/jsx_common.hrl:123: type format_opt() undefined
    ./include/jsx_common.hrl:85: type eep0018_key() undefined
    make[2]: *** [all] Error 1
    make[2]: Leaving directory `/home/hadoop-user/Software/thrift/lib/erl’
    make[1]: *** [install-recursive] Error 1
    make[1]: Leaving directory `/home/hadoop-user/Software/thrift/lib’
    make: *** [install-recursive] Error 1

Comments are closed.