侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

thrift安装遇到的问题以及解决方法(必看篇)

技术  /  管理员 发布于 7年前   368

1. 必须安装boost。最新的稳定版是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就可以了:

    主要内容涉及到安装的就2步,很简单,进入一级目录:
   
    $ ./bootstrap.sh //默认安装到/usr/local/include/boost 和/usr/local/lib下
    $ ./b2 install

1.3接下来设置环境变量自动导入:
   
   先用vim创建文件:/etc/profile.d/boost.sh,(若不能执行的话使用chmod a+x boost.sh设置执行权限),
  
   内容为:

#!/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程序运行时加载共享库出现的错误: "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 配置文件,这个文件记录了编译时使用的动态链接库的路径。 3、然后使用ldconfig命令,使配置生效。

2. 安装libevent(选择noblokingserver必须安装libevent,如果出现noblokingserver相关的错误就是没有安装libevent)。

我安装的版本是最新的libevent1.4.13:

wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gztar xvzf libevent-1.4.13-stable.tar.gzcd libevent-1.4.13-stable./configure && makemake 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 #makemake #installmake install

如果还需要编译Java或者别的语言,还需要提前安装别的包,具体参考http://wiki.apache.org/thrift/ThriftRequirements:

C++Boost 1.33.1+libevent (optional, to build the nonblocking server)zlib (optional)JavaJava 1.5+Apache AntApache Ivy (recommended)Apache Commons Lang (recommended)SLF4JC#: 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 5Bit::VectorClass::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

这样可以使预处理器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,在编译行加入相应的参数:

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,得到两个可执行文件,先执行CppServer,再启动CppClient。

到此,thrift安装完毕。

以上就是小编为大家带来的thrift安装遇到的问题以及解决方法(必看篇)全部内容了,希望大家多多支持~


  • 上一条:
    详解基于本地存储的kvm虚拟机在线迁移
    下一条:
    Thrift的安装方法和简单实例
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 2024.07.09日OpenAI将终止对中国等国家和地区API服务(0个评论)
    • 2024/6/9最新免费公益节点SSR/V2ray/Shadowrocket/Clash节点分享|科学上网|免费梯子(0个评论)
    • 国外服务器实现api.openai.com反代nginx配置(0个评论)
    • 2024/4/28最新免费公益节点SSR/V2ray/Shadowrocket/Clash节点分享|科学上网|免费梯子(0个评论)
    • 近期文章
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • 在go + gin中gorm实现指定搜索/区间搜索分页列表功能接口实例(0个评论)
    • 在go语言中实现IP/CIDR的ip和netmask互转及IP段形式互转及ip是否存在IP/CIDR(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • Laravel 11.15版本发布 - Eloquent Builder中添加的泛型(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-10
    • 2016-11
    • 2017-07
    • 2017-08
    • 2017-09
    • 2018-01
    • 2018-07
    • 2018-08
    • 2018-09
    • 2018-12
    • 2019-01
    • 2019-02
    • 2019-03
    • 2019-04
    • 2019-05
    • 2019-06
    • 2019-07
    • 2019-08
    • 2019-09
    • 2019-10
    • 2019-11
    • 2019-12
    • 2020-01
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2020-07
    • 2020-08
    • 2020-09
    • 2020-10
    • 2020-11
    • 2021-04
    • 2021-05
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-12
    • 2022-01
    • 2022-02
    • 2022-03
    • 2022-04
    • 2022-05
    • 2022-06
    • 2022-07
    • 2022-08
    • 2022-09
    • 2022-10
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-04
    • 2023-05
    • 2023-06
    • 2023-07
    • 2023-08
    • 2023-09
    • 2023-10
    • 2023-12
    • 2024-02
    • 2024-04
    • 2024-05
    • 2024-06
    • 2025-02
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客