This article mainly introduces how to compile thrift compiler in windows + Visual Studio 2013, there are tutorials on thrift official website: http://thrift.apache.org/docs/BuildingFromSource, but some of the places in it are outdated, the provided flex and bison tool download links have also expired, so this article has made some preparations based on the original tutorial.
Step 1: use git to download thrift source code
Git clone https://git-wip-us.apache.org/repos/asf/thrift.git thrift
Step 2: Compile
- Download unixutil, flex.exeand bison.exe: http://unxutils.sourceforge.net/
- Decompress unixutil.zip to Directory.
- Add Directory A to the Path of the Windows environment variable. Note that adding is not A replacement.
- Set bison. simple
- Download bison. simple and put it in directory B.
- Define Windows environment variablesBISON_SIMPLE = directory B \ bison. simple
- Download inttypes. h and place it in thrift \ compiler \ cpp \ src \
- Generate source code
- Go to thrift \ compiler \ cpp \ and execute the following command line:
Flex-osrc \ thriftl. cc src \ thriftl. ll
Comment out # include <unistd. h> in the generated thriftl. cc.
- Continue execution:
Bison-y-o "src/thrity. cc "-defines src/thrifle. yymove src \ thrifle. cc. hh src \ thrifle. hhmove src \ windows \ version. h. in src \ windows \ version. h
5. Use VS2013 to open thrift \ compiler \ cpp \ compiler. sln
6. Remove the content in BuildEvent from the project properties.
7. Compile the project. If everything goes well, you should be able to get the thrift.exe file.
Note: thrift has two files compiled (bison. simple and inttypes. h), which are hard to find. Download here: http://pan.baidu.com/s/1jGmmKqq
Thrift Compiler compilation steps