Friday, March 5, 2010

Getting in touch with Thrift - Simon says

Selected Simon Says from the Facebook Puzzle selection as this one seems to be the easiest example which involves the usage of Thrift. Thrift is right now a apache incubation project and is a framework for x-language service development. It has been initially developed by Facebook.

Let's see how to get Thrift working on my Ubuntu 9.10 system. First of all I downloaded the current snapshot from the Facebook Developer Pages ( in my case thrift-20090330.tar.gz). After unpacking a run of the ./configure script unveils a unsatisfied dependency on boost libraries. Synaptic comes with a couple of boost packages. I gave it a try with libboost-dev package (incl dependencies). With that the configure script was happy but the make command produces this nice error:

make[3]: Betrete Verzeichnis '/home/stefan/thrift-instant-r760184/compiler/cpp'
g++ -DHAVE_CONFIG_H -I. -I../.. -Wall -I./src -I/usr/include -g -O2 -MT thrift-thriftl.o -MD -MP -MF .deps/thrift-thriftl.Tpo -c -o thrift-thriftl.o `test -f 'thriftl.cc' || echo './'`thriftl.cc
In file included from ./src/parse/t_const.h:10,
from ./src/main.h:11,
from thriftl.ll:20:
./src/parse/t_type.h:88: error: ISO C++ forbids declaration of ‘uint8_t’ with no type
./src/parse/t_type.h:88: error: expected ‘;’ before ‘*’ token
./src/parse/t_type.h:92: error: expected ‘;’ before ‘std’
./src/parse/t_type.h:110: error: ‘uint8_t’ has not been declared
./src/parse/t_type.h:149: error: ‘uint8_t’ does not name a type
./src/parse/t_type.h: In member function ‘virtual void t_type::generate_fingerprint()’:
./src/parse/t_type.h:76: error: ‘fingerprint_’ was not declared in this scope
./src/parse/t_type.h: In member function ‘bool t_type::has_fingerprint() const’:
./src/parse/t_type.h:81: error: ‘fingerprint_’ was not declared in this scope
./src/parse/t_type.h: In member function ‘std::string t_type::get_ascii_fingerprint() const’:
./src/parse/t_type.h:94: error: expected initializer before ‘*’ token
./src/parse/t_type.h:96: error: ‘fp’ was not declared in this scope
./src/parse/t_type.h: In constructor ‘t_type::t_type()’:
./src/parse/t_type.h:123: error: ‘fingerprint_’ was not declared in this scope
./src/parse/t_type.h: In constructor ‘t_type::t_type(t_program*)’:
./src/parse/t_type.h:129: error: ‘fingerprint_’ was not declared in this scope
./src/parse/t_type.h: In constructor ‘t_type::t_type(t_program*, std::string)’:
./src/parse/t_type.h:136: error: ‘fingerprint_’ was not declared in this scope
./src/parse/t_type.h: In constructor ‘t_type::t_type(std::string)’:
./src/parse/t_type.h:143: error: ‘fingerprint_’ was not declared in this scope
thriftl.cc: In function ‘int yylex()’:
thriftl.cc:1449: warning: label ‘find_rule’ defined but not used
thriftl.cc: In function ‘int yy_get_next_buffer()’:
thriftl.cc:2389: warning: comparison between signed and unsigned integer expressions
thriftl.cc: At global scope:
thriftl.cc:2483: warning: ‘void yyunput(int, char*)’ defined but not used
thriftl.cc:3138: warning: ‘int yy_flex_strlen(const char*)’ defined but not used
make[3]: *** [thrift-thriftl.o] Fehler 1

I played a little bit with different versions of flex, bison and such a like, but I couldn't get this one running. While I was browsing for help, I found this nice blog entry from Robert J Berger which talks you through the installation of Thrift on a Ubuntu system. However mine still does not work.

As a x-check I downloaded the 0.2 Thrift release from the project homepage and tried to compile this. And this worked without any visible errors (note that you need to execute ./bootstrap.sh before running ./configure. Next step will be to test this installation and than keep fingers crossed that this one works for the Facebook Puzzles as well.