libevent-2.0.20-stable.tar.gz
boost_1_52_0.tar.gz
thrift-0.9.0.tar.gz
./configure --prefix=/usr/local/libevent
mk
mk install
./bootstrap.sh --prefix=/usr/local/boost
./b2
./b2 install
export CPPFLAGS="-DHAVE_NETDB_H=1 -fpermissive"
./configure --with-boost=/usr/local/boost/ --with-qt4=false --with-java=/usr/lib/jvm/java-7-sun/ --prefix=/usr/local/thrift
mk
mk install
生成C++代码,并测试,步骤如下:
1,在hbase/src/main/resources/org/apache/hadoop/hbase/thrift目录下
thrift --gen cpp Hbase.thrift
2,修改Makefile为下面内容:
INC = -I/usr/local/thrift/include -I/usr/local/thrift/include/thrift/ -I/usr/local/boost/include/
LIB = -L/usr/local/thrift/lib/ -lthriftGEN_SRC = ./gen-cpp/Hbase.cpp \
./gen-cpp/Hbase_types.cpp \
./gen-cpp/Hbase_constants.cpp
default: DemoClient
DemoClient: DemoClient.cpp
g++ -DHAVE_NETINET_IN_H -o DemoClient ${INC} -I./gen-cpp ${LIB} DemoClient.cpp ${GEN_SRC}
clean:
rm -rf DemoClient
注意:DemoClient.cpp本身有问题,需要对其做代码的注释来编译
3,修改环境,使编译后的DemoClient可以执行成功
# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
# echo "/usr/local/thrift/lib" >> /etc/ld.so.conf
# ldconfig
# ldconfig
或者
export LD_LIBRARY_PATH=/usr/local/thrift/lib:$LD_LIBRARY_PATH
4,运行:
先运行thrift服务:
/home/hadoop/hbase/bin/hbase thrift start
再运行DemoClient
./DemoClient 192.168.0.40 9090