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