tree: ac9c90ae8848240463b480693d61439acf1624ec [path history] [tgz]
  1. src/
  2. test/
  3. tests/
  4. CMakeLists.txt
  6. compiler.sln
  7. compiler.vcxproj
  8. compiler.vcxproj.filters

Build Thrift IDL compiler using CMake

Build on Unix-like System


  • Install CMake
  • Install flex and bison

Build using CMake

  • Go to thrift\compiler\cpp
  • Use the following steps to build using cmake:
mkdir cmake-build && cd cmake-build
cmake ..

Build with Eclipse IDE

  • Go to thrift\compiler\cpp
  • Use the following steps to build using cmake:
mkdir cmake-ec && cd cmake-ec
cmake -G "Eclipse CDT4 - Unix Makefiles" ..

Now open the folder cmake-ec using eclipse.

Build with XCode IDE in MacOS

  • Install/update flex, bison and cmake with brew
brew install cmake
brew install bison
  • Go to thrift\compiler\cpp
  • Run commands in command line:
mkdir cmake-build && cd cmake-build
cmake -G "Xcode" -DWITH_PLUGIN=OFF ..
cmake --build .

Usage of other IDEs

Please check list of supported IDE

cmake --help

Build on Windows


Build using Git Bash

Git Bash provides flex and bison

  • Go to thrift\compiler\cpp
  • Use the following steps to build using cmake:
mkdir cmake-vs && cd cmake-vs
cmake -DWITH_SHARED_LIB=off ..
cmake --build .

Using Visual Studio and Win flex-bison

  • Generate a Visual Studio project for version of Visual Studio which you have (cmake --help can show list of supportable VS versions):
  • Run commands in command line:
mkdir cmake-vs
cd cmake-vs
cmake -G "Visual Studio 15 2017" -DWITH_PLUGIN=OFF ..
  • Now open the folder cmake-vs using Visual Studio.

Cross compile using mingw32 and generate a Windows Installer with CPack

mkdir cmake-mingw32 && cd cmake-mingw32

Other cases

Building the Thrift IDL compiler in Windows without CMake

If you don't want to use CMake you can use the already available Visual Studio 2010 solution.

The Visual Studio project contains pre-build commands to generate the, and thrifty.hh files which are necessary to build the compiler.

These depend on bison, flex and their dependencies to work properly.

Download flex & bison as described above.

Place these binaries somewhere in the path and rename win_flex.exe and win_bison.exe to flex.exe and bison.exe respectively.

If this doesn't work on a system, try these manual pre-build steps.

Open compiler.sln and remove the Pre-build commands under the project's: Properties -> Build Events -> Pre-Build Events.

From a command prompt:

cd thrift/compiler/cpp
flex -o src\thrift\ src\thrift\thriftl.ll

In the generated, comment out #include <unistd.h>

Place a copy of bison.simple in thrift/compiler/cpp

bison -y -o "src/thrift/" --defines src/thrift/thrifty.yy
move src\thrift\  src\thrift\thrifty.hh

Bison might generate the yacc header file “” with just one h “.h” extension; in this case you'll have to rename to “thrifty.h”.

move src\thrift\ src\thrift\version.h

Download inttypes.h from the interwebs and place it in an include path location (e.g. thrift/compiler/cpp/src).

Build the compiler in Visual Studio.

Unit tests for compiler

Using boost test

  • pls check test folder

Using Catch C++ test library

Added generic way to cover code by tests for many languages (you just need to make a correct header file for generator for your language - example in netcore implementation)

  • pls check tests folder

Have a Happy free time and holidays