Contents
- Getting started
- Installation
- How it works?
- Running tutorial
- Our own Hello World
- Additional resources
- Comments
Disclaimer
This website, nor it's author isn't in any form affiliated or endorsed by the Apache Software Foundation.
Opinions or suggestions included in this document are based on the author's knowledge of Apache Thrift, which is still work-in-progress.
Installation of Apache Thrift
Download tar.gz archive from the download site, decompress archive in your home directory:
tar -xvzf thrift-0.2.0-incubating.tar.gz
Make sure, that you meet all dependencies (listed here). If not, install all needed packages - in debian it is as easy as typing:
apt-get install package-name
If you receive information such as
E: Couldn't find package (...)
type
apt-cache search package-name
to find proper name of the package (list could be long, so use | more or | grep package-name to navigate). For me, most troublesome was package libboost1.35-dev (I had problem with default libboost 1.34, despite the fact, that Apache Thrift requires only 1.33).
Ah, and don't forget to run apt-get as root (or using sudo).
So, go to the directory, where you unpacked the thrift and run
./configure
Important! Some manuals say, that you can run ./bootstrap.sh first, but it's not necessary. Running this command gave me a lot of trouble, so my suggestion is – don't do it. If you did – delete whole directory and unpack it one more time.
After running ./configure you may encounter this error:
checking for boostlib >= 1.33.1... configure: error: We could not detect the boost libraries (version 1.33 or higher). If you have a staged boost library (still not installed) please specify $BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.
Solution: I got rid of this error, when I installed libboost 1.35 instead of default libboost 1.34. If it still doesn't resolve the problem, try running configure with parameter stating the location of libboost In my case it was:
./configure --with-boost=/usr/include
I encountered also another error:
./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)'
Solution: install package pkg-config.
If ./configure finishes succesfully, run
make
Some of the errors, that you may encounter include:
../../ylwrap: line 109: yacc: command not found
Solution: install byacc package.
/root/thrift-0.2.0/missing: line 52: flex: command not found
WARNING: `flex' is missing on your system. You should only need it if
you modified a `.l' file. You may need the `Flex' package
in order for those modifications to take effect. You can get
`Flex' from any GNU archive site.
Solution: install flex package.
After installing additional packages you should re-run ./cofigure script. If "make" fails without any apparent reason, i.e.: on something like
/bin/sh ../../ylwrap `test -f 'src/thriftl.ll' || echo './'`src/thriftl.ll .c thriftl.cc -- /bin/sh /root/thrift-0.2.0/missing --run flex
it means you forgot to re-run ./configure.
After successful make, install Thrift by running
make install
with root privileges.
If you can run
thrift
command and see result like below – congratulations! You have thrift installed.
home-debian:~# thrift
Usage: thrift [options] file
Options:
-version Print the compiler version
-o dir Set the output directory for gen-* packages
(default: current directory)
-I dir Add a directory to the list of directories
searched for include directives
-nowarn Suppress all compiler warnings (BAD!)
-strict Strict compiler warnings on
-v[erbose] Verbose mode
-r[ecurse] Also generate included files
-debug Parse debug trace to stdout
--gen STR Generate code with a dynamically-registered generator.
STR has the form language[:key1=val1[,key2,[key3=val3]]].
Keys and values are options passed to the generator.
Many options will not require values.
Available generators (and options):
cocoa (Cocoa):
log_unexpected: Log every time an unexpected field ID or type is encountered.
cpp (C++):
dense: Generate type specifications for the dense protocol.
include_prefix: Use full include paths in generated files.
csharp (C#):
erl (Erlang):
hs (Haskell):
html (HTML):
java (Java):
beans: Generate bean-style output files.
nocamel: Do not use CamelCase field accessors with beans.
hashcode: Generate quality hashCode methods.
ocaml (OCaml):
perl (Perl):
php (PHP):
inlined: Generate PHP inlined files
server: Generate PHP server stubs
autoload: Generate PHP with autoload
oop: Generate PHP with object oriented subclasses
rest: Generate PHP REST processors
py (Python):
new_style: Generate new-style classes.
twisted: Generate Twisted-friendly RPC services.
rb (Ruby):
st (Smalltalk):
xsd (XSD):
