Thrift安装遇到的问题及解决方案
2015-01-04 10:18
253 查看
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步,很简单,进入一级目录:
1.3接下来设置环境变量自动导入:
先用vim创建文件:/etc/profile.d/boost.sh,(若不能执行的话使用chmoda+x
boost.sh设置执行权限),
内容为:
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):
如果还需要编译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 Studio2005+
Python 2.4+ (including header files for extension modules)
PHP 5.0+ (optionally including header files for extensionmodules)
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 cpptutorial.thrift,
会在gen-cpp目录下生成一些文件。然后进入CPP目录,进行编译:
make
有可能遇到错误,提示: hton*declarations will not be visible to thecompiler。这是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 compilererror when HAVE_NETINET_IN_H is not defined.
[/code]
This might be a bug in the Thrift configure script which somehowskips 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安装完毕。
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,(若不能执行的话使用chmoda+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 Studio2005+
Python 2.4+ (including header files for extension modules)
PHP 5.0+ (optionally including header files for extensionmodules)
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 cpptutorial.thrift,
会在gen-cpp目录下生成一些文件。然后进入CPP目录,进行编译:
make
有可能遇到错误,提示: hton*declarations will not be visible to thecompiler。这是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 compilererror when HAVE_NETINET_IN_H is not defined.
#ifdef HAVE_NETINET_IN_H #include <netinet/in.h> #endif
[/code]
This might be a bug in the Thrift configure script which somehowskips 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安装遇到的问题及解决方案
- 安装和卸载FlyakiteOSX遇到问题的解决方案
- SQL Server 2008 安装过程中遇到“性能计数器注册表配置单元一致性”检查失败 问题的解决方案
- 预装Windows 7的联想笔记本电脑 重新安装XP系统遇到花屏问题的解决方案
- Oracle安装过程中遇到的一些问题及解决方案
- [zz]安装oracle 10g经常会遇到的问题解决方案
- windows8下U盘安装ubuntu,非wubi安装,遇到的问题以及解决方案
- 从安装mysql到初学时遇到的问题及解决方案 推荐
- snort安装过程中遇到的问题及解决方案
- ubuntu下安装matlab时遇到Permission denied问题的解决方案
- 在iXWebHosting上安装WordPress遇到的问题,及解决方案
- 笔记本新机全新安装XP时遇到问题的解决方案(针对新的Vista机型装xp的解决方案)
- FC9的硬盘安装及遇到的问题和解决方案
- [ubuntu] ubuntu13.04 64bit,安装FastDFS4.06过程遇到的问题和解决方案
- 安装.net2008后,再安装.net2003,运行项目时遇到的问题解决方案!
- 上网本 Ubuntu下安装android遇到的问题及解决方案
- 我在安装oracle遇到的问题以及解决方案
- Rosetta stone安装过程中遇到的问题和解决方案
- nagios 安装与配置以及遇到一些问题的解决方案
- 各种版本的linux下安装多个版本的NS2(比如ns2.31和ns2.27)中遇到的问题和解决方案