blob: 1d6e2086b7b71089a0d43d5cddda217283e5b312 [file] [log] [blame] [view]
Roger Meiere9f00cb2014-05-30 14:35:34 +02001---
2title: "Windows Install"
3kind: doc
4---
5## Windows Setup
6The windows compiler is available as a prebuilt exe available [here](/download)
7
8---
9
10## Windows setup from source
11
12### Basic requirements for win32
13Thrift's compiler is written in C++ and designed to be portable, but there are some system requirements:
14
15 * Cygwin or MinGW
16 * [Apache Thrift Requirements](/docs/install)
17
18Thrift's runtime libraries are written in various languages, which are also required for the particular language interface.
19
20### Installing from source
21If you are building from the first time out of the source repository, you will need to generate the configure scripts. (This is not necessary if you downloaded a tarball.) From the top directory, do:
22
23 ./bootstrap.sh
24
25Once the configure scripts are generated, thrift can be configured. From the top directory, do:
26
27 export CXXFLAGS="-D PTHREAD_MUTEX_RECURSIVE_NP=PTHREAD_MUTEX_RECURSIVE"
28 ./configure
29
30Setting the CXXFLAGS environmental variable works around compile errors with PTHREAD_MUTEX_RECURSIVE_NP being undeclared, by replacing it with the newer, portable PTHREAD_MUTEX_RECURSIVE. (Tested on cygwin 20100320, Thrift r760184, latest pthread.)
31
32**Optional:** You **may not** be able to make from the root Thrift directory due to errors (see below to resolve). To make the compiler only, change to the compiler directory before running make:
33
34 cd compiler/cpp
35
36Now make the thrift compiler (& runtime libraries if make is run from the thrift root directory):
37
38 make
39 make install
40
41Some language packages must be installed manually using build tools better suited to those languages (at the time of this writing, this applies to Java, Ruby, PHP).
42
43Look for the README file in the `lib/<language>/` folder for more details on the installation of each language library package.
44
45### Possible issues with Cygwin install
46See also Possible issues with MinGW install.
47
48#### Syntax error in ./configure
49The following error occurs for some users when running ./configure:
50
51 ./configure: line 21183: syntax error near unexpected token `MONO,'
52 ./configure: line 21183: ` PKG_CHECK_MODULES(MONO, mono >= 1.2.6, have_mono=yes, have_mono=no)'
53
54To resolve this, you'll need to find your pkg.m4 (installed by the pkg-config package) file and copy it to the thrift/aclocal directory. From the top-level thrift directory, you can copy the file by running
55
56 cp /usr/share/aclocal/pkg.m4 aclocal
57
58Finally, re-run ./bootstrap.sh and ./configure. (Note that pkg.m4 is created by the pkg-config tool. If your /usr/share/aclocal directory doesn't contain the pkg.m4 file, you may not have pkg-config installed.)
59
60#### Installing perl runtime libraries
61Sometimes, there will be an error during the install of the perl libraries with chmod.
62
63A workaround is to avoid installing the perl libraries if they are not needed.
64
65If you don't need perl, run configure with --without-perl.
66
67If you need perl, and are happy to manually install it, replace the contents of thrift/lib/perl/Makefile with the following, after building thrift:
68
69 TODO
70
71#### Linking to installed C++ runtime libraries
72Sometimes, the installed libthrift.a will not link using g++, with linker errors about missing vtables and exceptions for Thrift classes.
73
74A workaround is to link the compiled object files directly from your Thrift build, corresponding to the missing classes.
75
76This can be implemented in a Makefile using the following lines:
77
78 THRIFT_O=<path to>/thrift/lib/cpp
79 LTHRIFT=$(THRIFT_O)/Thrift.o $(THRIFT_O)/TSocket.o $(THRIFT_O)/TBinaryProtocol.o $(THRIFT_O)/TBufferTransports.o
80
81Then linking using $(LTHRIFT) instead of -lthrift.
82
83 TODO - diagnose issue further
84
85#### C++ runtime segfault with cygwin 1.7.5-1, g++-4.3.4, fork() and throw
86
87If your thrift C++ programs segfault on throw after fork()ing, compile them with g++-3.
88
89The issue and patch are described on the Cygwin mailing list at http://cygwin.com/ml/cygwin/2010-05/msg00203.html
90
91This issue should be fixed in Cygwin versions after 1.7.5-1, or g++ 4.5.0.
92
93## Installation from Source (No Cygwin dependency)
94To compile the Thrift generator & runtime libraries (untested) without the cygwin.dll dependency you need to install MinGW (www.mingw.org). In addition you need to add the following entry to your windows PATH variable.
95
96 C:\MINGW\BIN
97
98Next, open compiler/cpp/Makefile.am and add the following line to thrift_CXXFLAGS
99
100 -DMINGW -mno-cygwin -lfl
101
102Run bootstrap.sh:
103
104 ./bootstrap.sh
105
106Make sure you have java in your $PATH variable, if not do(adjust path if necessary):
107
108 export PATH=$PATH:"/cygdrive/c/program files/java/jre1.6.0_05/bin"
109
110Run configure - using CXXFLAGS to work around an issue with an old pthreads define (untested on MinGW - works on Cygwin):
111
112 export CXXFLAGS="-D PTHREAD_MUTEX_RECURSIVE_NP=PTHREAD_MUTEX_RECURSIVE"
113 ./configure
114
115''Optional:'' To make the compiler only, change to the compiler directory before running make:
116
117 cd compiler/cpp
118
119Run make:
120
121 mingw32-make.exe
122
123### Possible issues with MinGW install
124See also Possible issues with Cygwin install, including the discussion about PTHREAD_MUTEX_RECURSIVE_NP.
125
126#### yywrap is not found
127Make sure you add -lfl in your cxxflags in Makefile, also try adding -Lc:/cygwin/libs
128
129#### boost is not found
130Try and change the include dir to use the windows path from c like this: Edit compiler/cpp/Makefile, look for the declaration of BOOST_CPPFLAGS, change that line for
131
132 BOOST_CPPFLAGS = -Ic:/cygwin/usr/include/boost-1_33_1
133
134#### realpath is not found
135add -DMINGW -mno-cygwin to the CXXDEFS variable in Makefile
136
137## Additional reading
138
139For more information on the requirements see: [Apache Thrift Requirements](/docs/install)
140
141For more information on building and installing Thrift see: [Building from source](/docs/BuildingFromSource)
142