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