wiki:CompileWithMinGW

Compiling Box Backup on Windows with MinGW

This page describes an experimental work in progress to build Box Backup on Windows using MinGW only, without Cygwin. If in doubt, please use the Cygwin and MinGW build process instead.

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

MinGW C++

Start by downloading the  automated MinGW installer. During installation, select the C++ compiler and the MSYS environment.

After installation, run the MinGW Shell application, and use the mingw-get command-line tool to install additional packages:

mingw-get update
mingw-get install msys-perl msys-m4 msys-autoconf msys-automake

Use the pwd command to check whether your home directory (based on your Windows account name) contains spaces. If it does, rename it to something that doesn't:

mv '/home/Chris Wilson' /home/chris

and add a corresponding HOME= line to /etc/profile, and close and reopen the MinGW shell:

HOME=/home/chris

If you are going to check out the code from our Subversion repository, rather than using a distribution tarball, please download the Subversion command-line client as well, and use it to check out the code.

Base Directory

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

C:\MinGW\msys\1.0\home\YourNameWithoutSpaces

Make sure you know the full path to this directory, and that it does not contain ANY spaces.

Zlib

Download the latest  Zlib source code, e.g.  zlib 1.2.5, and save it in your base directory.

Open the MinGW Shell, go to the base directory, and unpack Zlib:

tar xzvf zlib-1.2.5.tar.gz

Build and install it:

cd zlib-1.2.5
make -f win32/Makefile.gcc
make -f win32/Makefile.gcc install INCLUDE_PATH=/usr/local/include BINARY_PATH=/usr/local/bin LIBRARY_PATH=/usr/local/lib

OpenSSL

Download the  OpenSSL 1.0.0a source code.

Open the MinGW Shell, go to the base directory, and unpack OpenSSL:

tar xzvf openssl-1.0.0a.tar.gz

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

cd openssl-1.0.0a
./Configure mingw zlib --with-zlib-include=/usr/local/include --with-zlib-lib=/usr/local/lib -DOPENSSL_NO_CAPIENG
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 the latest PCRE 8.x from  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

Open the MinGW Shell, go to the base directory, and unpack PCRE:

tar xjvf pcre-8.10.tar.bz2

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

cd pcre-8.10
./configure
make
make install

(so far so good, what follows is currently untested.)

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
./configure --with-ssl-headers=/usr/local/ssl/include --with-ssl-lib=/usr/local/ssl/lib CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib LIBS="-lwsock32 -lgdi32"
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.