1<!--- 2Licensed under the Apache License, Version 2.0 (the "License"); 3you may not use this file except in compliance with the License. 4You may obtain a copy of the License at 5 6 http://www.apache.org/licenses/LICENSE-2.0 7 8Unless required by applicable law or agreed to in writing, software 9distributed under the License is distributed on an "AS IS" BASIS, 10WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11See the License for the specific language governing permissions and 12limitations under the License. 13--> 14 15# Building thrift on Windows (MinGW64/MSYS2) 16 17Thrift uses cmake to make it easier to build the project on multiple platforms, however to build a fully functional and production ready thrift on Windows requires a number of third party libraries to be obtained. Once third party libraries are ready, the right combination of options must be passed to cmake in order to generate the correct environment. 18 19> Note: libevent and libevent-devel do not work with this toolchain as they do not properly detect mingw64 and expect some headers to exist that do not, so the non-blocking server is not currently built into this solution. 20 21## MSYS2 22 23Download and fully upgrade msys2 following the instructions at: 24 25 https://msys2.github.io/ 26 27Install the necessary toolchain items for C++: 28 29 $ pacman --needed -S bison flex make mingw-w64-x86_64-openssl \ 30 mingw-w64-x86_64-boost mingw-w64-x86_64-cmake \ 31 mingw-w64-x86_64-toolchain mingw-w64-x86_64-zlib 32 33Update your msys2 bash path to include /mingw64/bin by adding a line to your ~/.bash_profiles using this command: 34 35 echo "export PATH=/mingw64/bin:\$PATH" >> ~/.bash_profile 36 37After that, close your shell and open a new one. 38 39Use cmake to create a MinGW makefile, out of tree (assumes you are in the top level of the thrift source tree): 40 41 mkdir ../thrift-build 42 cd ../thrift-build 43 cmake -G"MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=/mingw64/bin/mingw32-make \ 44 -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc.exe \ 45 -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++.exe \ 46 -DWITH_LIBEVENT=OFF \ 47 -DWITH_SHARED_LIB=OFF -DWITH_STATIC_LIB=ON \ 48 -DWITH_JAVA=OFF -DWITH_PYTHON=OFF -DWITH_PERL=OFF \ 49 ../thrift 50 51Build thrift (inside thrift-build): 52 53 cmake --build . 54 55Run the tests (inside thrift-build): 56 57 ctest 58 59> If you run into issues, check Apache Jira THRIFT-4046 for patches relating to MinGW64/MSYS2 builds. 60 61## Tested With 62 63msys2 64-bit 2016-10-26 distribution 64