wiki:CompileWithCygwinMinGW

Compiling Box Backup on Windows with Cygwin's MinGW

This page describes how you can build Box Backup on Windows using Cygwin and their version of MinGW. This is how my windows client releases are normally compiled. Note that although Cygwin is normally used to build POSIX software to run on Windows with an emulation layer, in this case we use the Cygwin port of the MinGW compiler to produce native executables that don't need the emulation layer. We do this because the Box Backup build process requires several Unix utilities that make it difficult to build on Windows without some emulation layer.

You will need quite a bit of software to make this work (hundreds of megabytes). All of it is available for free on the Internet.

Cygwin works well, but it's quite slow, so I'm experimenting with using MinGW alone.

How to build Box Backup on Win32 using Cygwin and MinGW By Chris Wilson, 2009-03-31

(To read this document online with better formatting, browse to: http://www.boxbackup.org/trac/wiki/CompileWithMinGW)

MinGW C++

Start by installing Cygwin on your Windows machine from  http://www.cygwin.org/cygwin/.

Make sure to select the following packages during installation:

  • Archive/unzip
  • Devel/automake
  • Devel/autoconf
  • Devel/gcc-mingw
  • Devel/gcc-mingw-g++
  • Devel/make
  • Libs/libxml2
  • Libs/libxslt (for xsltproc)
  • Mingw/mingw-zlib-devel
  • Perl/Perl?

If you already have Cygwin installed, please re-run the installer and ensure that those packages are installed.

You may also want to install:

  • Devel/gdb (the debugger)
  • Devel/subversion (the command-line Subversion client)
  • Editors/vim (the Vim text editor)

Base Directory

Choose a directory where you will unpack and compile OpenSSL, Zlib and Box Backup. We will call this the base directory. An example might be:

	C:\Cygwin\Home\YourUsername

Make sure you know the full path to this directory.

If your user name has spaces in it, which is quite common on Windows, please rename your home directory to one without any spaces, and change your user's home directory in /etc/passwd to match.

OpenSSL

Download OpenSSL from  http://www.openssl.org/source/openssl-1.0.1.tar.gz

Open a Cygwin shell, go to the base directory, and unpack OpenSSL:

	tar xzvf openssl-1.0.1.tar.gz

Configure OpenSSL for MinGW compilation, and build and install it:

	cd openssl-1.0.1
	./Configure --prefix=/usr/i686-pc-mingw32/ mingw
	make
	make install_sw

PCRE

This step is only required to support regular expressions in including/excluding files from backups. However, this is a very useful feature.

Download PCRE from  http://prdownloads.sourceforge.net/pcre/pcre-8.12.tar.bz2?download.

Open a Cygwin shell, go to the base directory, and unpack, build and install PCRE:

	tar xjvf pcre-8.12.tar.bz2
	cd pcre-8.12
	export CFLAGS="-mno-cygwin"
	export CXXFLAGS="-mno-cygwin"
	./configure --prefix=/usr/i686-pc-mingw32 --disable-shared
	make 
	make install

Note: we must disable shared libraries on Windows because otherwise libpcreposix.a is built to depend on libpcre.dll, even if you define PCRE_STATIC, and since /usr/i686-pc-mingw32/bin (the location of the DLL) is not normally on the PATH, the DLL can't be found, which stops you from running any executables.

Readline (Optional)

Readline enables editing and completion of commands in bbackupquery. It is optional, but it makes bbackupquery easier to use. However, please do not enable readline if you intend to distribute the resulting Box Backup binaries, as this would be a violation of the GPL license of readline.

If you want Readline support, download PDCurses from  http://sourceforge.net/projects/pdcurses/files/pdcurses/3.4/PDCurses-3.4.tar.gz/download. Save it in your base directory, then open a Cygwin shell there, unpack it, compile and install it:

	tar xzvf PDCurses-3.4.tar.gz
	cd PDCurses-3.4/win32
	make -f gccwin32.mak CC="gcc -mno-cygwin" LINK="gcc -mno-cygwin"
	cp pdcurses.a /usr/i686-pc-mingw32/lib/libpdcurses.a

Download Readline version 6.2 from  ftp://ftp.cwru.edu/pub/bash/readline-6.2.tar.gz, and unpack and install it thus:

	tar xzvf readline-6.2.tar.gz
	cd readline-6.2
	./configure --prefix=/usr/i686-pc-mingw32 \
		CFLAGS="-mno-cygwin" \
		CPPFLAGS="-mno-cygwin" \
		LDFLAGS="-mno-cygwin" \
		LIBS="-lpdcurses" \
		--with-curses --disable-shared
	make
	make install

Download Box Backup

Go back to the base directory, and download the latest Box Backup sources:

	svn co https://www.boxbackup.org/svn/box/trunk/ trunk

Note: If you have problems during the configure or make stage, please try to eliminate one potential source of problems by running the following command to convert all line endings to Unix format:

	find -type f -not \( -wholename .*svn*. \) -exec dos2unix {} \;

Compile Box Backup

Enter the source directory and configure like this:

	cd trunk
	./infrastructure/mingw/configure.sh [--enable-gnu-readline]
	make

Installation

Create the destination directory, C:\Program Files\Box Backup\bbackupd.

Write a configuration file, keys and certificate on a Unix machine, and copy them into the Box Backup directory, together with the following files from the base directory:

  • boxbackup\release\bin\bbackupd\bbackupd.exe
  • boxbackup\release\bin\bbackupquery\bbackupquery.exe
  • boxbackup\release\bin\bbackupctl\bbackupctl.exe
  • openssl\out32dll\libeay32.dll
  • openssl\out32dll\ssleay32.dll
  • zlib\zlib1.dll

Ensure that the user running Box Backup can read from the Box Backup directory, and write to the bbackupd directory inside it.

Run Box Backup by double-clicking on it, and check that it connects to the server. If the window opens and closes immediately, it's probably due to a problem with the configuration file. Check the Windows Event Viewer for details.

See also the service installation and upgrade instructions on the CompilationOnWindows page.