How to compile the Couchbase stack on Windows
Installing a build environment
Download and install the latest "fullversion" of msysgit from http://code.google.com/p/msysgit/downloads/list.
msysgit contains bash, gcc and other commonly used Unix tools. Unfortunately the installed compiler can't compile a 64 bit binary, so you need to install another compiler for that...
- http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Automated%20Builds/mingw-w32-1.0-bin_i686-mingw_20100906.zip/download
You "install" the compiler by extracting the zipfile (normally, into c:\msysgit\msysgit\mingw64) and add the bin folder to your path.
You should also consider adding the following to your .bashrc file:
PATH=/mingw64/bin:$PATH export PATH
You need to download (and install) pthreads for the 64 bit compiler. A binary package is available from: http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/pthreads/pthreads-20100604.zip/download. Extract the file named pthreads-w64.zip within the zip file into /mingw64 .
The rest of the compilation steps should be performed from a msysgit shell.
Directory Structure
To be able to compile both 32-bit and 64-bit applications, installation of compiled binaries will be into /tmp/membase-build32 for 32-bit applications and /tmp/membase-build64 for 64-bit applications.
Build dependencies
Install libevent
Download http://monkey.org/~provos/libevent-2.0.7-rc.tar.gz and install it with the following commands:
gunzip libevent-2.0.7-rc.tar.gz tar xf libevent-2.0.7-rc.tar cd libevent-2.0.7-rc ./configure --prefix=/tmp/membase-build32 --disable-shared make all install cd .. rm -rf libevent-2.0.7-rc tar xf libevent-2.0.7-rc.tar cd libevent-2.0.7-rc ./configure --prefix=/tmp/membase-build64 --disable-shared --host=x86_64-w64-mingw32 --build=i686-pc-mingw32 make all install
Install cURL
Download http://curl.haxx.se/download/curl-7.21.1.tar.gz and install it with the following commands:
gunzip curl-7.21.1.tar.gz tar xf curl-7.21.1.tar cd curl-7.21.1.tar cd curl-7.21.1 rm Makefile
Next, patch libtool in order to build a shared libraries on Windows. Apply the following patch:
--- curl-7.21.1-org/ltmain.sh 2010-05-27 21:20:16.000000000 +0200 +++ curl-7.21.1/ltmain.sh 2010-09-13 10:00:38.862248879 +0200 @@ -6685,6 +6685,19 @@ done done fi + + if test -n "$a_deplib" + then + case "$a_deplib" in + -lws2_32 | -lwldap32 | -lpthread) + newdeplibs+=" $a_deplib" + a_deplib="" + ;; + *) + ;; + esac + fi + if test -n "$a_deplib" ; then droppeddeps=yes $ECHO
Now build it with the following commands:
./configure --prefix=/tmp/membase-build64 --disable-static --enable-shared --host=x86_64-w64-mingw32 --build=i686-pc-mingw32
Build the Couchbase Stack
There is a Makefile that you may use build everything from scratch. "autoconf" tools are not available on Windows, so you need to log into a UNIX machine first to generate a configure file for all of the sub-projects couchbase is built up of. To do so, run the following commands:
git clone git://github.com/trondn/tools
cd tools/membase
mkdir win32 win64
ln -s ../Makefile win32/Makefile
ln -s ../Makefile win64/Makefile
cd win32
make -j preparesource
cd ../win64
make -j preparesource
cd ..
Due to the bug in libtool we need to apply the content of the patch above (it may not apply unless you are using the same version of libtool, but it's fairly easy to manually add.. Just search for "linker path" and add the content above the block).
If you've a patch file that applies cleanly you can fix all of the source with the following commands:
for f in `find . -name ltmain.sh` do cd `dirname $f` patch -p1 < /tmp/libtool.patch cd - done
You should now be able to build everything by running the following commands on your windows box:
for f in win32 win64 do cd $f make $f cd .. done