ubuntu 16.04 编译thrift0.11.0

安装环境

     ~~~~     编译thrift需要一些工具和第三方库,我们需要提取安装好,我们操作都是在有网的情况下。注意我这里boost是编译的,所有没有使用apt-get添加,也可以使用apt-get直接添加。

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

下载

     ~~~~     直接去官网下载就可以了,还有就是去github上下载也可以,下面是地址。
     ~~~~     官网:http://thrift.apache.org/
     ~~~~     github:https://github.com/apache/thrift
     ~~~~     官网版本是在更新的,我的版本是0.11,如果想要我的版本可以联系我。

编译安装

     ~~~~     下载好了,复制到ubuntu上:

qilimi@sharenew-desktop:~/work$ tar -zxvf thrift-0.11.0.tar.gz
...
qilimi@sharenew-desktop:~/work$ ls
boost_1_64_0  thrift-0.11.0  thrift-0.11.0.tar.gz
qilimi@sharenew-desktop:~/work$ rm thrift-0.11.0.tar.gz
qilimi@sharenew-desktop:~/work$ cd thrift-0.11.0/
qilimi@sharenew-desktop:~/work/thrift-0.11.0$ ls
aclocal       bootstrap.sh  CHANGES         compile        config.guess  config.sub    contrib          depcomp   install-sh    LICENSE      Makefile.in  package.json              test            ylwrap
aclocal.m4    bower.json    cleanup.sh      compiler       config.h      configure     CONTRIBUTING.md  doap.rdf  LANGUAGES.md  ltmain.sh    missing      README.md                 Thrift.podspec
appveyor.yml  build         CMakeLists.txt  composer.json  config.hin    configure.ac  debian           doc       lib           Makefile.am  NOTICE       sonar-project.properties  tutorial

     ~~~~     很多时候编译我们都是去百度找,其实在这种开源项目里面都是有文档的,我们只需要找到文档查看,就会有编译说明,这里我们直接打开文件 R E A D M E . m d README.md README.md,就可以在文件后面看到怎么编译的部分。

qilimi@sharenew-desktop:~/work/thrift-0.11.0$ cat README.md
Apache Thrift
=============

Last Modified: 2017-11-10
...
Installation
============

If you are building from the first time out of the source repository, you will
need to generate the configure scripts.  (This is not necessary if you
downloaded a tarball.)  From the top directory, do:

    ./bootstrap.sh

Once the configure scripts are generated, thrift can be configured.
From the top directory, do:

    ./configure

You may need to specify the location of the boost files explicitly.
If you installed boost in /usr/local, you would run configure as follows:

    ./configure --with-boost=/usr/local

Note that by default the thrift C++ library is typically built with debugging
symbols included. If you want to customize these options you should use the
CXXFLAGS option in configure, as such:

    ./configure CXXFLAGS='-g -O2'
    ./configure CFLAGS='-g -O2'
    ./configure CPPFLAGS='-DDEBUG_MY_FEATURE'

To enable gcov required options -fprofile-arcs -ftest-coverage enable them:

    ./configure  --enable-coverage

Run ./configure --help to see other configuration options

Please be aware that the Python library will ignore the --prefix option
and just install wherever Python's distutils puts it (usually along
the lines of /usr/lib/pythonX.Y/site-packages/).  If you need to control
where the Python modules are installed, set the PY_PREFIX variable.
(DESTDIR is respected for Python and C++.)

Make thrift:

        make

From the top directory, become superuser and do:

        make install

Note that some language packages must be installed manually using build tools
better suited to those languages (at the time of this writing, this applies
to Java, Ruby, PHP).

Look for the README.md file in the lib/<language>/ folder for more details on the
installation of each language library package.

Testing
=======

There are a large number of client library tests that can all be run
from the top-level directory.

          make -k check

This will make all of the libraries (as necessary), and run through
the unit tests defined in each of the client libraries. If a single
language fails, the make check will continue on and provide a synopsis
at the end.

To run the cross-language test suite, please run:

          make cross

This will run a set of tests that use different language clients and
servers.

Development
===========

To build the same way Travis CI builds the project you should use docker.
We have [comprehensive building instructions for docker](build/docker/README.md).
qilimi@sharenew-desktop:~/work/thrift-0.11.0$

     ~~~~     安装测试都是有的,我们安装步骤来:

qilimi@sharenew-desktop:~/work/thrift-0.11.0$ ./bootstrap.sh
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE [^\}]*}/ at /usr/bin/autoscan line 361.
configure.ac:93: installing './config.guess'
configure.ac:93: installing './config.sub'
configure.ac:27: installing './install-sh'
configure.ac:27: installing './missing'
compiler/cpp/Makefile.am: installing './depcomp'
configure.ac: installing './ylwrap'
qilimi@sharenew-desktop:~/work/thrift-0.11.0$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
...
If something is missing that you think should be present,
please skim the output of configure to find the missing
component.  Details are present in config.log.

qilimi@sharenew-desktop:~/work/thrift-0.11.0$ make
make  all-recursive
make[1]: Entering directory '/home/qilimi/work/thrift-0.11.0'
Making all in compiler/cpp
make[2]: Entering directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp'
...
make[3]: Leaving directory '/home/qilimi/work/thrift-0.11.0/tutorial'
make[2]: Leaving directory '/home/qilimi/work/thrift-0.11.0/tutorial'
make[2]: Entering directory '/home/qilimi/work/thrift-0.11.0'
make[2]: Leaving directory '/home/qilimi/work/thrift-0.11.0'
make[1]: Leaving directory '/home/qilimi/work/thrift-0.11.0'
qilimi@sharenew-desktop:~/work/thrift-0.11.0$ 

     ~~~~     这里就编译完成了,注意make之后,看一下最后的打印,开有没有报错,有报错就要根据保存来解决问题了,我这里没有报错。
之后就是安装测试,安装注意加sudo,因为需要权限复制文件。
测试:

qilimi@sharenew-desktop:~/work/thrift-0.11.0$ make -k check
Making check in compiler/cpp
make[1]: Entering directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp'
Making check in src
make[2]: Entering directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/src'
make  check-am
make[3]: Entering directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/src'
make[3]: Nothing to be done for 'check-am'.
make[3]: Leaving directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/src'
make[2]: Leaving directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/src'
Making check in src/thrift/plugin
make[2]: Entering directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/src/thrift/plugin'
make  check-am
make[3]: Entering directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/src/thrift/plugin'
make[3]: Nothing to be done for 'check-am'.
make[3]: Leaving directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/src/thrift/plugin'
make[2]: Leaving directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/src/thrift/plugin'
Making check in .
make[2]: Entering directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp'
make[2]: Nothing to be done for 'check-am'.
make[2]: Leaving directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp'
Making check in test
make[2]: Entering directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/test'
make
make[3]: Entering directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/test'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/test'
make  check-TESTS
make[3]: Entering directory '/home/qilimi/work/thrift-0.11.0/compiler/cpp/test'
==================
All 0 tests passed
==================
...

     ~~~~     我的电脑只有C++的环境,其他语言肯定是运行不了的,要注意看,只要C++的测试过了就行了。
如果想看怎么在ubuntu下使用cmake编译thrift例子,可以去CMake在ubuntu下的使用(4).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值