欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

thrift安裝遇到的問(wèn)題以及解決方法(必看篇)

 更新時(shí)間:2016年12月20日 10:00:38   投稿:jingxian  
下面小編就為大家?guī)?lái)一篇thrift安裝遇到的問(wèn)題以及解決方法(必看篇)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

1. 必須安裝boost。最新的穩(wěn)定版是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.安裝過(guò)程和以前的老版本有些不同,看自帶軟件包里的index.html就可以了:

    主要內(nèi)容涉及到安裝的就2步,很簡(jiǎn)單,進(jìn)入一級(jí)目錄:
   
    $ ./bootstrap.sh //默認(rèn)安裝到/usr/local/include/boost 和/usr/local/lib下
    $ ./b2 install

1.3接下來(lái)設(shè)置環(huán)境變量自動(dòng)導(dǎo)入:
   
   先用vim創(chuàng)建文件:/etc/profile.d/boost.sh,(若不能執(zhí)行的話使用chmod a+x boost.sh設(shè)置執(zhí)行權(quán)限),
  
   內(nèi)容為:

#!/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程序運(yùn)行時(shí)加載共享庫(kù)出現(xiàn)的錯(cuò)誤: "error while loading shared libraries: xxxx: cannot open shared object file: No such file or directory" 解決步驟: 1、使用find命令查找缺失的xxxx共享庫(kù)文件所在位置。參考:#find 目錄 -name "xxxx*" 2、將找到的目錄位置寫(xiě)入 /etc/ld.so.conf 配置文件,這個(gè)文件記錄了編譯時(shí)使用的動(dòng)態(tài)鏈接庫(kù)的路徑。 3、然后使用ldconfig命令,使配置生效。

2. 安裝libevent(選擇noblokingserver必須安裝libevent,如果出現(xiàn)noblokingserver相關(guān)的錯(cuò)誤就是沒(méi)有安裝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. 接下來(lái)就是安裝thrift,我下載的是最新的thrift0.8.0版本,進(jìn)入thrift0.8.0目錄:

 因?yàn)槲抑恍枰幾gcpp,用以下命令:(編譯選項(xiàng)可以參考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或者別的語(yǔ)言,還需要提前安裝別的包,具體參考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先試驗(yàn)一下。進(jìn)入thrift下的tutorial,編譯給出的例子:

thrift -r --gen cpp tutorial.thrift,

會(huì)在gen-cpp目錄下生成一些文件。然后進(jìn)入CPP目錄,進(jìn)行編譯:

make

有可能遇到錯(cuò)誤,提示: hton* declarations will not be visible to the compiler。這是thrift的一個(gè)bug,可能有的版本沒(méi)有該錯(cuò)誤,但是我安裝的這個(gè)版本有。解決的辦法是:

使用g++編譯時(shí)加入 -DHAVE_NETINET_IN_H

這樣可以使預(yù)處理器include進(jìn) netinet/in.h in thrift/protocol/TPrototol.h, 這樣 hton* declarations will be visible to the compiler.

下面是一個(gè)老外對(duì)這個(gè)bug的說(shuō)明:

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.

針對(duì)上面的那個(gè)例子,修改CPP文件夾里的Makefile,在編譯行加入相應(yīng)的參數(shù):

g++ -DHAVE_NETINET_IN_H -o CppServer -I${THRIFT_DIR} -I${BOOST_DIR}  -I../gen-cpp -L${LIB_DIR} -lthrift CppServer.cpp ${GEN_SRC}

再進(jìn)行make,得到兩個(gè)可執(zhí)行文件,先執(zhí)行CppServer,再啟動(dòng)CppClient。

到此,thrift安裝完畢。

以上就是小編為大家?guī)?lái)的thrift安裝遇到的問(wèn)題以及解決方法(必看篇)全部?jī)?nèi)容了,希望大家多多支持腳本之家~

相關(guān)文章

最新評(píng)論