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

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

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

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.安裝過程和以前的老版本有些不同,看自帶軟件包里的index.html就可以了:

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

1.3接下來設(shè)置環(huán)境變量自動導(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程序運行時加載共享庫出現(xiàn)的錯誤: "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 配置文件,這個文件記錄了編譯時使用的動態(tài)鏈接庫的路徑。 3、然后使用ldconfig命令,使配置生效。

2. 安裝libevent(選擇noblokingserver必須安裝libevent,如果出現(xiàn)noblokingserver相關(guān)的錯誤就是沒有安裝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

這樣可以使預(yù)處理器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,在編譯行加入相應(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}

再進行make,得到兩個可執(zhí)行文件,先執(zhí)行CppServer,再啟動CppClient。

到此,thrift安裝完畢。

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

相關(guān)文章

最新評論