1. 必须安装boost。最新的稳定版是1.48.0。
1.1.先下载:http://sourceforge.NET/projects/boost/files/boost/1.48.0/
选择tar.gz包,
下载后我解压到了/usr/local/boost_1_48下:tar zxvf boost1.48.0 -C /usr/local/boost_1_48
1.2.安装过程和以前的老版本有些不同,看自带软件包里的index.html就可以了:
主要内容涉及到安装的就2步,很简单,进入一级目录:
$ ./bootstrap.sh //默认安装到/usr/local/include/boost 和/usr/local/lib下
$ ./b2 install
1.3接下来设置环境变量自动导入:
先用vim创建文件:/etc/profile.d/boost.sh,(若不能执行的话使用chmod a+x boost.sh设置执行权限),
内容为:
#!/bin/sh #boost settings BOOST_ROOT=/opt/boost_1_48 BOOST_INCLUDE=/usr/local/include/boost BOOST_LIB=/usr/local/lib export BOOST_ROOT BOOST_INCLUDE BOOST_LIB 注意: linux程序运行时加载共享库出现的错误: "error while loading shared libraries: xxxx: cannot open shared object file: No such file or directory" 解决步骤: 1、使用find命令查找缺失的xxxx共享库文件所在位置。参考:#find 目录 -name "xxxx*" 2、将找到的目录位置写入 /etc/ld.so.conf 配置文件,这个文件记录了编译时使用的动态链接库的路径。 3、然后使用ldconfig命令,使配置生效。
2. 安装libevent(选择noblokingserver必须安装libevent,如果出现noblokingserver相关的错误就是没有安装libevent)。
我安装的版本是最新的libevent1.4.13:
wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz tar xvzf libevent-1.4.13-stable.tar.gz cd libevent-1.4.13-stable ./configure && make make install
3. 接下来就是安装thrift,我下载的是最新的thrift0.8.0版本,进入thrift0.8.0目录:
因为我只需要编译cpp,用以下命令:(编译选项可以参考http://www.coder4.com/archives/2110):
./configure --with-cpp --with-boost --without-python --without-csharp --without-java --without-erlang --without-perl --without-php --without-php_extension --without-ruby --without-haskell --without-go #make make #install make install
如果还需要编译Java或者别的语言,还需要提前安装别的包,具体参考http://wiki.apache.org/thrift/ThriftRequirements:
C++ Boost 1.33.1+ libevent (optional, to build the nonblocking server) zlib (optional) Java Java 1.5+ Apache Ant Apache Ivy (recommended) Apache Commons Lang (recommended) SLF4J C#: Mono 1.2.4+ (and pkg-config to detect it) or Visual Studio 2005+ Python 2.4+ (including header files for extension modules) PHP 5.0+ (optionally including header files for extension modules) Ruby 1.8+ (including header files for extension modules) Erlang R12 (R11 works but not recommended) Perl 5 Bit::Vector Class::Accessor
安装完thrift先试验一下。进入thrift下的tutorial,编译给出的例子:
thrift -r --gen cpp tutorial.thrift,
会在gen-cpp目录下生成一些文件。然后进入CPP目录,进行编译:
make
有可能遇到错误,提示: hton* declarations will not be visible to the compiler。这是thrift的一个bug,可能有的版本没有该错误,但是我安装的这个版本有。解决的办法是:
使用g++编译时加入 -DHAVE_NETINET_IN_H
这样可以使预处理器include进 netinet/in.h in thrift/protocol/TPrototol.h, 这样 hton* declarations will be visible to the compiler.
下面是一个老外对这个bug的说明:
TProtocol.h has the following lines which cause the compiler error when HAVE_NETINET_IN_H is not defined.
#ifdef HAVE_NETINET_IN_H #include <netinet/in.h> #endif
This might be a bug in the Thrift configure script which somehow skips the define.
针对上面的那个例子,修改CPP文件夹里的Makefile,在编译行加入相应的参数:
g++ -DHAVE_NETINET_IN_H -o CppServer -I${THRIFT_DIR} -I${BOOST_DIR} -I../gen-cpp -L${LIB_DIR} -lthrift CppServer.cpp ${GEN_SRC}
再进行make,得到两个可执行文件,先执行CppServer,再启动CppClient。
到此,thrift安装完毕。
以上就是小编为大家带来的thrift安装遇到的问题以及解决方法(必看篇)全部内容了,希望大家多多支持~
thrift安装
更新日志
- 坣娜.1998-别恋【非常喜】【WAV+CUE】
- 《草原经典 最炫草原风 2CD》[WAV/分轨][980MB]
- 《不烧不选 经典国语极品珍藏》[WAV/分轨][500MB]
- 《绝对主打 流行原创金曲 2CD》[WAV分轨][1.1GB]
- 《赛博朋克2077》更新上线:支持AMD FSR3
- 《塞尔达传说:智慧的再现》提前半个月偷跑,引发玩家担忧
- 战锤40K星际战士2全职业介绍|全职业技能效果一览
- 陈百强《2006世纪10星·永恒篇[环球]》[WAV整轨]
- 【新世纪钢琴】VA-GoldenOctober(Piano)(金秋十月钢琴篇)【FLAC】
- 青稞荞麦《破茧》新生代组合[WAV+CUE]
- 因系统升级后出现BUG 《FF16》PS5完全版宣布延期
- 《黑神话:悟空》周伯通!大佬用左右手分别挑战两只虎先锋
- 《黑神话:悟空》攻击动作致敬《大话西游》:这也太帅了!
- 《星舰铳犬太阳系物语》游戏背景介绍
- 《战锤40K星际战士2》终极版有后续DLC说明