Skip to end of metadata
Go to start of metadata

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...

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
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.