ubuntu安装thrift

环境要求如下

Basic requirements

  • A relatively POSIX-compliant *NIX system
    • Cygwin or MinGW can be used on Windows (but there are better options, see below)
  • g++ 4.2 (4.8 or later required for thrift compiler plug-in support)
  • boost 1.53.0
    • Runtime libraries for lex and yacc might be needed for the compiler

Requirements for building from source

  • GNU build tools:
    • autoconf 2.65
    • automake 1.13
    • libtool 1.5.24
  • pkg-config autoconf macros (pkg.m4)
  • lex and yacc (developed primarily with flex and bison)
  • libssl-dev

开始安装基础环境

sudo apt-get install automake bison flex g++ git libboost1.55-all-dev libevent-dev libssl-dev libtool make pkg-config

如果是Debian 7/Ubuntu 12还需要手动安装automake,boost

wget http://ftp.br.debian.org/debian/pool/main/a/automake-1.15/automake_1.15-6_all.deb
sudo dpkg -i automake_1.15-6_all.deb

wget http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz                                                                      
tar xvf boost_1_60_0.tar.gz
cd boost_1_60_0
./bootstrap.sh
sudo ./b2 install

wget http://archive.apache.org/dist/thrift/0.9.2/thrift-0.9.2.tar.gz
tar -zxvf thrift-0.9.2.tar.gz
cd thrift-0.9.2

编译安装,这里采用默认安装

./configure
make
make install 

查看版本

thrift -version
Thrift version 0.9.2

测试编写person.thrift

namespace java com.fan.hadoop.parquet.thrift

struct Person{
    1:optional string name;
    2:optional i32 age;
}

生成java类

thrift --gen java person.thrift

生成路径如下

├── gen-java
│   └── com
│       └── fan
│           └── hadoop
│               └── parquet
│                   └── thrift
│                       └── Person.java
└── person.thrift

猜你喜欢

转载自blog.csdn.net/woloqun/article/details/80648607