Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Thrift Wiki" for change 
notification.

The "ThriftInstallationWin32" page has been changed by TimWilson-Brown.
The comment on this change is: added info about compiling thrift runtime 
libraries on windows, with some provisos. Needs further work.
http://wiki.apache.org/thrift/ThriftInstallationWin32?action=diff&rev1=16&rev2=17

--------------------------------------------------

- The following instructions are for making the thrift ''compiler'' only.  The 
Thrift C++ runtime library does not currently work on Windows.  This means that 
you'll be able to compile [[ThriftIDL]] files to C++/Java/Python/etc., but you 
won't be able to compile and run the generated C++ code under Windows.
+ The following instructions reliably install the thrift ''compiler'' only.  
The Thrift C++ runtime library'' may not'' compile on Windows.  This means that 
you'll be able to compile [[ThriftIDL]] files to C++/Java/Python/etc., but you 
''may not'' be able to compile and run the generated C++ code under Windows.
  
  == Basic requirements for win32 ==
  Thrift's compiler is written in C++ and designed to be portable, but there 
are some system requirements:
+ 
-   * Cygwin or MinGW
+  * Cygwin or MinGW
-   * GNU build tools (autoconf 2.60, automake 1.10, libtool 1.5.24)
+  * GNU build tools (autoconf 2.60, automake 1.10, libtool 1.5.24)
-   * boost 1.33.1+
+  * boost 1.33.1+
-   * g++ 4.0+
+  * g++ 4.0+
-   * bison 2.3-1
+  * bison 2.3-1
-   * boost 1.33.1-4
+  * boost 1.33.1-4
-   * boost-devel 1.33.1-4
+  * boost-devel 1.33.1-4
-   * flex 2.5.33-1
+  * flex 2.5.33-1
-   * pkgconfig
+  * pkgconfig
-   * libtool
+  * libtool
  
  == Installation steps (Cygwin dependency) ==
+ 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:
+ 
- 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:
  {{{
-       ./bootstrap.sh
+         ./bootstrap.sh
  }}}
- Once the configure scripts are generated, thrift can be configured.
+ Once the configure scripts are generated, thrift can be configured. From the 
top directory, do:
- From the top directory, do:
+ 
  {{{
-       ./configure
+         export CXXFLAGS="-D 
PTHREAD_MUTEX_RECURSIVE_NP=PTHREAD_MUTEX_RECURSIVE"
+         ./configure
  }}}
+ 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.)
  
- Now make the thrift compiler:
+ ''Optional:'' You ''may not'' be able to make from the root  Thrift 
directory--If you try to make from that directory, there may be  errors 
compiling the Thrift C++ runtime libraries, installing the perl  libraries, and 
linking to the installed Thrift C++ runtime libraries. To make the compiler 
only, change to the compiler directory before running make:
+ 
  {{{
          cd compiler/cpp
-       make
  }}}
+ Now make the thrift compiler (& runtime libraries if make is run from the 
thrift root directory):
  
- (You won't be able to make from the root Thrift directory--If you try to make 
from that directory, you'll get compile errors about PTHREAD_MUTEX_RECURSIVE_NP 
undeclared.  Making from compiler/cpp creates the Thrift compiler, while making 
from the root Thrift directory creates, among other things, the Thrift C++ 
runtime libraries, which are known not to compile under Cygwin/Windows.)
+ {{{
+         make
+         make install
+ }}}
+ 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).
  
- 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).
- 
- Look for the README file in the lib/<language>/ folder for more details on the
+ Look for the README file in the lib/<language>/ folder for more details on 
the installation of each language library package.
- installation of each language library package.
  
  === Possible issues with Cygwin install ===
+ See also Possible issues with MinGW install.
+ 
  ==== Syntax error in ./configure ====
  The following error occurs for some users when running ./configure:
+ 
  {{{
  ./configure: line 21183: syntax error near unexpected token `MONO,'
  ./configure: line 21183: `  PKG_CHECK_MODULES(MONO, mono >= 1.2.6, 
have_mono=yes, have_mono=no)'
  }}}
  To resolve this, you'll need to find your pkg.m4 file and copy it to the 
thrift/aclocal directory.  From the top-level thrift directory, you can copy 
the file by running
+ 
  {{{
          cp /usr/share/aclocal/pkg.m4 aclocal
  }}}
  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.)
  
+ ==== Installing perl runtime libraries ====
+ Sometimes, there will be an error during the install of the perl libraries 
with chmod.
+ 
+ A workaround is to avoid installing the perl libraries if they are not needed.
+ 
+ This can be achieved by replacing the contents of thrift/lib/perl/Makefile 
with the following, after building thrift:
+ 
+ {{{
+         install:
+ }}}
+ TODO - Fix
+ 
+ ==== Linking to installed C++ runtime libraries ====
+ Sometimes, the installed libthrift.a will not link using g++, with linker 
errors about missing vtables and exceptions for Thrift classes.
+ 
+ A workaround is to link the compiled object files directly from your Thrift 
build, corresponding to the missing classes.
+ 
+ This can be implemented in a Makefile using the following lines:
+ 
+ {{{
+         THRIFT_O=<path to>/thrift/lib/cpp
+         LTHRIFT=$(THRIFT_O)/Thrift.o $(THRIFT_O)/TSocket.o 
$(THRIFT_O)/TBinaryProtocol.o $(THRIFT_O)/TBufferTransports.o
+ }}}
+ Then linking using $(LTHRIFT) instead of -lthrift.
+ 
+ TODO - diagnose issue further
+ 
  == Installation steps(No Cygwin dependency) ==
+ To compile the Thrift generator 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.
  
- To compile the Thrift generator 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.
  {{{
         C:\MINGW\BIN
  }}}
+ Next, open compiler/cpp/Makefile.am and add the following line to 
thrift_CXXFLAGS
  
- Next, open compiler/cpp/Makefile.am and add the following line to 
thrift_CXXFLAGS
  {{{
  -DMINGW -mno-cygwin -lfl
  }}}
+ Run bootstrap.sh:
  
- Run bootstrap.sh: 
  {{{
   ./bootstrap.sh
  }}}
+ Make sure you have java in your $PATH variable, if not do(adjust path if 
necessary):
  
- Make sure you have java in your $PATH variable, if not do(adjust path if 
necessary): 
  {{{
   export PATH=$PATH:"/cygdrive/c/program files/java/jre1.6.0_05/bin"
  }}}
+ Run configure
  
- Run configure
  {{{
   ./configure
  }}}
+ Run make
  
- 
- Run make
  {{{
     cd compiler/cpp
     mingw32-make.exe
  }}}
- 
  === Possible issues with MinGW install ===
+ See also Possible issues with Cygwin install.
  
  ==== yywrap is not found ====
- Make sure you add -lfl in your cxxflags in Makefile, also try adding 
-Lc:/cygwin/libs 
+ Make sure you add -lfl in your cxxflags in Makefile, also try adding 
-Lc:/cygwin/libs
  
  ==== boost is not found ====
- 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
+ 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
+ 
  {{{
  BOOST_CPPFLAGS = -Ic:/cygwin/usr/include/boost-1_33_1
  }}}
- 
  ==== realpath is not found ====
- 
  add -DMINGW -mno-cygwin to the CXXDEFS variable in Makefile
  

Reply via email to