]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | ## Windows Setup |
2 | ||
3 | The Thrift environment consists of two main parts: The Thrift compiler EXE and the language-dependent libraries. Most of these libraries will require some kind of build and/or installation. But regarding the Thrift compiler utility there are a number of different alternatives. | |
4 | ||
5 | The first one of these alternatives is to download the **pre-built Thrift Compiler EXE** and only build the libraries needed from source, following one of the "Setup from source" methods outlined below. | |
6 | ||
7 | The other two options are to build the Thrift compiler from source. The most recommended way to achieve this is by means of the **Visual Studio C++ build project**. Alternatively, the Thrift compiler can also be built via **Cygwin** or **MinGW** build environments, however this method is not only less comfortable, but more time-consuming and requires much more manual effort. | |
8 | ||
9 | ||
10 | ## Prebuilt Thrift compiler | |
11 | ||
12 | The windows Thrift compiler is available as a prebuilt exe available [here](/download). Note that there is no installation tool, rather this EXE file *is* already the Thrift compiler utility. Download the file and put it into some suitable location of your choice. | |
13 | ||
14 | Now pick one of the "Build and install target libraries" below to continue. | |
15 | ||
16 | ||
17 | ## Setup from source via Visual Studio C++ (recommended) | |
18 | ||
19 | ### Requirements | |
20 | ||
21 | Thrift's compiler is written in C++ and designed to be portable, but there are some system requirements. Thrift's runtime libraries are written in various languages, which are also required for the particular language interface. | |
22 | ||
23 | * Visual Studio C++, any recent version should do | |
24 | * Flex and Bison, e.g. the WinFlexBison package | |
25 | * [Apache Thrift Requirements](/docs/install) | |
26 | ||
27 | ### Build and install the compiler | |
28 | ||
29 | After all requirements are in place, use the `compiler/cpp/compiler.vcxproj` build project to build the Thrift compiler. Copy the resulting EXE file to a location of your choice. | |
30 | ||
31 | ### Build and install target libraries | |
32 | ||
33 | A few of the target language libraries also do provide Visual Studio project files, such as C++ and C#. These are located in the `lib/<language>/` folders. | |
34 | ||
35 | Most of the language packages must be built and installed manually using build tools better suited to those languages. Typical examples are Java, Ruby, Delphi, or PHP. Look for the `README.md` file in the `lib/<language>/` folder for more details on how to build and install each language's library package. | |
36 | ||
37 | ||
38 | ## Setup from source via Cygwin | |
39 | ||
40 | ### Requirements | |
41 | ||
42 | Thrift's compiler is written in C++ and designed to be portable, but there are some system requirements. Thrift's runtime libraries are written in various languages, which are also required for the particular language interface. | |
43 | ||
44 | * Cygwin or MinGW | |
45 | * [Apache Thrift Requirements](/docs/install) | |
46 | ||
47 | ### Installing from source | |
48 | ||
49 | If 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: | |
50 | ||
51 | ./bootstrap.sh | |
52 | ||
53 | Once the configure scripts are generated, thrift can be configured. From the top directory, do: | |
54 | ||
55 | export CXXFLAGS="-D PTHREAD_MUTEX_RECURSIVE_NP=PTHREAD_MUTEX_RECURSIVE" | |
56 | ./configure | |
57 | ||
58 | Setting 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.) | |
59 | ||
60 | **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: | |
61 | ||
62 | cd compiler/cpp | |
63 | ||
64 | Now make the thrift compiler (& runtime libraries if make is run from the thrift root directory): | |
65 | ||
66 | make | |
67 | make install | |
68 | ||
69 | ### Build and install target libraries | |
70 | ||
71 | Some language packages must be installed manually using build tools better suited to those languages. Typical examples are Java, Ruby, or PHP. Look for the README file in the `lib/<language>/` folder for more details on the installation of each language library package. | |
72 | ||
73 | ### Possible issues with Cygwin install | |
74 | ||
75 | See also Possible issues with MinGW install. | |
76 | ||
77 | #### Syntax error in ./configure | |
78 | ||
79 | The following error occurs for some users when running ./configure: | |
80 | ||
81 | ./configure: line 21183: syntax error near unexpected token `MONO,' | |
82 | ./configure: line 21183: ` PKG_CHECK_MODULES(MONO, mono >= 1.2.6, have_mono=yes, have_mono=no)' | |
83 | ||
84 | To 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 | |
85 | ||
86 | cp /usr/share/aclocal/pkg.m4 aclocal | |
87 | ||
88 | Finally, 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.) | |
89 | ||
90 | #### Installing perl runtime libraries | |
91 | ||
92 | Sometimes, there will be an error during the install of the perl libraries with chmod. | |
93 | ||
94 | A workaround is to avoid installing the perl libraries if they are not needed. | |
95 | ||
96 | If you don't need perl, run configure with --without-perl. | |
97 | ||
98 | If you need perl, and are happy to manually install it, replace the contents of thrift/lib/perl/Makefile with the following, after building thrift: | |
99 | ||
100 | TODO | |
101 | ||
102 | #### Linking to installed C++ runtime libraries | |
103 | ||
104 | Sometimes, the installed libthrift.a will not link using g++, with linker errors about missing vtables and exceptions for Thrift classes. | |
105 | ||
106 | A workaround is to link the compiled object files directly from your Thrift build, corresponding to the missing classes. | |
107 | ||
108 | This can be implemented in a Makefile using the following lines: | |
109 | ||
110 | THRIFT_O=<path to>/thrift/lib/cpp | |
111 | LTHRIFT=$(THRIFT_O)/Thrift.o $(THRIFT_O)/TSocket.o $(THRIFT_O)/TBinaryProtocol.o $(THRIFT_O)/TBufferTransports.o | |
112 | ||
113 | Then linking using $(LTHRIFT) instead of -lthrift. | |
114 | ||
115 | TODO - diagnose issue further | |
116 | ||
117 | #### C++ runtime segfault with cygwin 1.7.5-1, g++-4.3.4, fork() and throw | |
118 | ||
119 | If your thrift C++ programs segfault on throw after fork()ing, compile them with g++-3. | |
120 | ||
121 | The issue and patch are described on the Cygwin mailing list at http://cygwin.com/ml/cygwin/2010-05/msg00203.html | |
122 | ||
123 | This issue should be fixed in Cygwin versions after 1.7.5-1, or g++ 4.5.0. | |
124 | ||
125 | ## Setup from source via MinGW | |
126 | ||
127 | ### Requirements | |
128 | ||
129 | To compile the Thrift generator & runtime libraries (untested) without the cygwin.dll dependency you need to install MinGW (www.mingw.org). | |
130 | ||
131 | * MinGW | |
132 | * [Apache Thrift Requirements](/docs/install) | |
133 | ||
134 | In addition you need to add the following entry to your windows PATH variable. | |
135 | ||
136 | C:\MINGW\BIN | |
137 | ||
138 | Next, open compiler/cpp/Makefile.am and add the following line to thrift_CXXFLAGS | |
139 | ||
140 | -DMINGW -mno-cygwin -lfl | |
141 | ||
142 | Run bootstrap.sh: | |
143 | ||
144 | ./bootstrap.sh | |
145 | ||
146 | Make sure you have java in your $PATH variable, if not do(adjust path if necessary): | |
147 | ||
148 | export PATH=$PATH:"/cygdrive/c/program files/java/jre1.8.0_191/bin" | |
149 | ||
150 | Run configure - using CXXFLAGS to work around an issue with an old pthreads define (untested on MinGW - works on Cygwin): | |
151 | ||
152 | export CXXFLAGS="-D PTHREAD_MUTEX_RECURSIVE_NP=PTHREAD_MUTEX_RECURSIVE" | |
153 | ./configure | |
154 | ||
155 | ''Optional:'' To make the compiler only, change to the compiler directory before running make: | |
156 | ||
157 | cd compiler/cpp | |
158 | ||
159 | Run make: | |
160 | ||
161 | mingw32-make.exe | |
162 | ||
163 | ### Possible issues with MinGW install | |
164 | ||
165 | See also Possible issues with Cygwin install, including the discussion about PTHREAD_MUTEX_RECURSIVE_NP. | |
166 | ||
167 | #### yywrap is not found | |
168 | ||
169 | Make sure you add -lfl in your cxxflags in Makefile, also try adding -Lc:/cygwin/libs | |
170 | ||
171 | #### boost is not found | |
172 | ||
173 | Try 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 | |
174 | ||
175 | BOOST_CPPFLAGS = -Ic:/cygwin/usr/include/boost-1_53_0 | |
176 | ||
177 | #### realpath is not found | |
178 | ||
179 | add -DMINGW -mno-cygwin to the CXXDEFS variable in Makefile | |
180 | ||
181 | ## Additional reading | |
182 | ||
183 | For more information on the requirements see: [Apache Thrift Requirements](/docs/install) | |
184 | ||
185 | For more information on building and installing Thrift see: [Building from source](/docs/BuildingFromSource) | |
186 |