Thrift Compiler 编译步骤


    本文主要介绍怎么在windows+VisualStudio 2013 下编译 thrift compiler,  在thrift官网有教程: http://thrift.apache.org/docs/BuildingFromSource,  不过里面有些地方过时了,提供的flex和bison工具下载链接也已失效, 所以本文在原教程基础上做了一些整理。

 

第一步: 使用git 下载 thrift源码

git clone https://git-wip-us.apache.org/repos/asf/thrift.git thrift

 

第二步:编译

  1. 下载 unixutil, 我们需要里面包含的flex.exe和bison.exe:http://unxutils.sourceforge.net/
    1. 解压 unixutil.zip到 目录A
    2. 将目录A添加到Windows环境变量Path中去, 注意是添加不是替换.
  2. 设置bison.simple
    1. 下载bison.simple, 放到目录B中
    2. 定义Windows环境变量 BISON_SIMPLE = 目录B\bison.simple
  3. 下载inttypes.h, 放到 thrift\compiler\cpp\src\
  4. 生成源码
    1. 命令行下转到 thrift\compiler\cpp\ 下, 执行如下命令行:
      flex -osrc\thriftl.cc src\thriftl.ll

      在生成的thriftl.cc中 注释掉 #include <unistd.h>

    2. 继续执行:
      bison -y -o “src/thrifty.cc” –defines src/thrifty.yy
      move src\thrifty.cc.hh  src\thrifty.hh
      move src\windows\version.h.in src\windows\version.h

 

5. 使用VS2013, 打开thrift\compiler\cpp\compiler.sln

6. 在项目属性中, 去掉BuildEvent中的内容

7. 编译项目, 一切顺利的话, 应该能够得到thrift.exe文件

 

注: thrift 编译有两个文件(bison.simple 和 inttypes.h),  比较难找到,在此下载: http://pan.baidu.com/s/1jGmmKqq

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM