Apache Thift的开发环境搭建
Ubantu12.04环境:
第一步,安装依赖:
sudo apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev
sudo apt-get install python-dev automake libtool flex bison pkg-config g++
注:
需要的依赖库:
- g++ 4.2
- boost 1.40.0
- Runtime libraries for lex and yacc might be needed for the compiler
编译源码需要的类库
- GNU build tools:
- autoconf 2.65
- automake 1.9
- libtool 1.5.24
- pkg-config autoconf macros (pkg.m4)
- lex and yacc (developed primarily with flex and bison)
- libssl-dev
如果出现以下错误
错误 http://cn.archive.ubuntu.com/ubuntu/ maverick-s/main xbase-clients all 1:7.5+6ubuntu3.1
解析“cn.archive.ubuntu.com:http”时,呈现了某些故障(-5 - No address associated with hostname)
错误 http://cn.archive.ubuntu.com/ubuntu/ maverick/universe vnc4server amd64 4.1.1+xorg4.3.0-37ubuntu2
解析“cn.archive.ubuntu.com:http”时,呈现了某些故障(-5 - No address associated with hostname)
错误 http://cn.archive.ubuntu.com/ubuntu/ maverick/universe xrdp amd64 0.5.0~20100303cvs-4
解析“cn.archive.ubuntu.com:http”时,呈现了某些故障(-5 - No address associated with hostname)
错误 http://security.ubuntu.com/ubuntu/ maverick-security/main xbase-clients all 1:7.5+6ubuntu3.1
解析“security.ubuntu.com:http”时,呈现了某些故障(-5 - No address associated with hostname)
无法下载 http://security.ubuntu.com/ubuntu/pool/main/x/xorg/xbase-clients_7.5+6ubuntu3.1_all.deb 解析“security.ubuntu.com:http”时,呈现了某些故障 (-5 - No address associated with hostname)No address associated with hostname)
E: 有几个软件包无法下载,您可以运行 apt-get 或者加上 --fix-missing 的选项再尝尝?
这是由于服务器域名配置问题,将正确的域名设置到resolv.conf就能解决,如下所示:
echo ""nameserver 192.168.0.1"" >> /etc/resolv.conf echo ""nameserver 88.8.8.8"" >> /etc/resolv.conf
/etc/init.d/networking restart
第二步,intall:
解压缩源码包,进入源码包目录。
如果下载的是纯源码方式,则需要运行./bootstrap.sh。
如果是tar包格式,直接运行
./configure
(注:如果后面补充安装依赖库,则需要执行make clean,然后重新执行./configure)
You may need to specify the location of the boost files explicitly. If you installed boost in /usr/local, you would run configure as follows:
./configure --with-boost=/usr/local
If you want to override the logic of the detection of the Java SDK, use the JAVAC environment variable:
./configure JAVAC=/usb/bin/javac
Note that by default the thrift C++ library is typically built with debugging symbols included. If you want to customize these options you should use the CXXFLAGS option in configure, as such:
./configure CXXFLAGS='-g -O2'
./configure CFLAGS='-g -O2'
./configure CPPFLAGS='-DDEBUG_MY_FEATURE'
To see other configuration options run
./configure --help
Once you have run configure you can build Thrift via make:
make
and run the test suite:
make check
Issues while compiling
-
“compiler/cpp/thriftl.cc:2190: undefined reference to yywrap'”
you need to install the Flex library (See also Apache Thrift Requirements ) and re-run the configuration script.
-
mv: cannot stat “'.deps/TBinaryProtocol.Tpo': No such file or directory” while building the Thrift Runtime Library
Re-reun configure with
--enable-libtool-lockor by turning off parallel make by placing .NOTPARALLEL: in lib/cpp/Makefile or
make -j 1Although the thrift compiler build appears to be compatible with parallel make without libtool lock, the thrift runtime build is not.
Installing
From the top directory, become superuser and do:
make install
Note that some language packages must be installed manually using build tools better suited to those languages (this applies to Java, Ruby, PHP).
Look for the README file in the lib// folder for more details on the installation of each language library package.
浙公网安备 33010602011771号