[Box Backup] Working instructions to cross-compile Box Backup trunk under Ubuntu Hardy

Achim boxbackup@boxbackup.org
Tue, 24 Mar 2009 13:35:55 +0100


Hello list:

Please find below the detailed instructions of how to cross-compile Box
Backup trunk under Ubuntu Hardy. "Minor" issue: the build process works
fine, but running the executables on Windows results in a segfault. Any
views on how to find out the reason? I do not have much debugging
experience (or tools for that matter), so any ideas are welcome!

> bbackupquery.exe -v
NOTICE:  Box Backup Query Tool vtrunk_2463M, (c) Ben Summers and
contributors 2003-2008
INFO:    Using configuration file
D:\install\boxbackup\cli.2463\bbackupd.conf
[boom]


> bbackupd.exe
WARNING:
==============================================================================
SECURITY WARNING: This platform cannot check the credentials of connections
to
the command socket. This is a potential DoS security problem.
Remove the CommandSocket directive from the bbackupd.conf file if
bbackupctl
is not used.
==============================================================================

NOTICE:  Starting daemon, version: trunk_2463M
NOTICE:  Using configuration file:
D:\install\boxbackup\cli.2463\bbackupd.conf
[boom]


====== HOWTO cross-compile Box Backup trunk under Ubuntu Hardy =====
aptitude install wine binfmt-support mingw32 mingw-zlib mingw32-binutils
mingw32-runtime

/etc/init.d/binfmt-support start

* * * zlib * * *
wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar xvzf zlib-1.2.3.tar.gz
cd zlib-1.2.3
export CC=i586-mingw32msvc-gcc 
export AR="i586-mingw32msvc-ar rc" 
export RANLIB="i586-mingw32msvc-ranlib"
./configure
make
make install prefix=/usr/local/i586-mingw32msvc


[reset CC, AR, RANLIB variables:]
export CC=
export AR=
export RANLIB=


* * * OpenSSL * * *
wget http://www.openssl.org/source/openssl-0.9.8b.tar.gz
tar xzvf openssl-0.9.8b.tar.gz
cd openssl-0.9.8b
./Configure --prefix=/usr/local/i586-mingw32msvc mingw
make makefile.one
wget
http://www.boxbackup.org/svn/box/chris/win32/support/openssl-0.9.8b-mingw-cross.patch
patch -p1 < openssl-0.9.8b-mingw-cross.patch
make -f makefile.one
make -f makefile.one install


Building OpenSSL
mkdir /usr/local/i586-mingw32msvc
mkdir: cannot create directory `/usr/local/i586-mingw32msvc': File exists
make: [install] Error 1 (ignored)
mkdir /usr/local/i586-mingw32msvc/bin
mkdir /usr/local/i586-mingw32msvc/include
mkdir: cannot create directory `/usr/local/i586-mingw32msvc/include': File
exists
make: [install] Error 1 (ignored)
mkdir /usr/local/i586-mingw32msvc/include/openssl
mkdir /usr/local/i586-mingw32msvc/lib
mkdir: cannot create directory `/usr/local/i586-mingw32msvc/lib': File
exists
make: [install] Error 1 (ignored)
/bin/cp outinc/openssl/*.[ch] /usr/local/i586-mingw32msvc/include/openssl
/bin/cp out/openssl /usr/local/i586-mingw32msvc/bin
/bin/cp apps/openssl.cnf /usr/local/i586-mingw32msvc
/bin/cp out/libssl.a /usr/local/i586-mingw32msvc/lib
/bin/cp out/libcrypto.a /usr/local/i586-mingw32msvc/lib



* * * PCRE * * *
wget http://prdownloads.sourceforge.net/pcre/pcre-6.3.tar.bz2?download
tar xjvf pcre-6.3.tar.bz2
cd pcre-6.3
export AR=i586-mingw32msvc-ar
./configure --host=i586-mingw32msvc --prefix=/usr/local/i586-mingw32msvc/
make winshared

If you get this error:

	./dftables.exe pcre_chartables.c
	/bin/bash: ./dftables.exe: cannot execute binary file
	make: *** [pcre_chartables.c] Error 126

then run:

	wine ./dftables.exe pcre_chartables.c
	make winshared

to complete the build. Finally:

cp .libs/libpcre.a /usr/local/i586-mingw32msvc/lib
cp .libs/libpcreposix.a /usr/local/i586-mingw32msvc/lib
cp pcreposix.h /usr/local/i586-mingw32msvc/include

WARNING: The original instructions are inconsistent here and use
/usr/local/i386-pc-mingw32/ as the destination directory instead of
/usr/local/i386-mingw32 as before (note the -pc- part!)


[reset AR variable]
export AR=



* * * mingwm10.dll * * * 
You will need to find a copy of mingwm10.dll that matches your
cross-compiler.
Most MinGW distributions should come with it. On Debian and Ubuntu, for
some
bizarre reason, you'll find it compressed as
/usr/share/doc/mingw32-runtime/mingwm10.dll.gz, in which case you'll
have to un-gzip it with "gzip -d". Copy it to a known location, e.g.
/usr/local/i586-mingw32msvc/bin.


cp /usr/share/doc/mingw32-runtime/mingwm10.dll.gz
/usr/local/i586-mingw32msvc/bin
gunzip /usr/local/i586-mingw32msvc/bin/mingwm10.dll.gz




* * * Box Backup * * * 
Download and extract Box Backup, and change into the base directory,

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

cd trunk

[update path to /usr/local/i586-mingw32msvc/bin/mingwm10.dll in 
parcels.txt]

./bootstrap
/usr/share/aclocal/libmcrypt.m4:17: warning: underquoted definition of 
AM_PATH_LIBMCRYPT
/usr/share/aclocal/libmcrypt.m4:17:   run info '(automake)Extending
aclocal'
/usr/share/aclocal/libmcrypt.m4:17:   or see 
http://sources.redhat.com/automake/automake.html#Extending-aclocal

./configure --host=i586-mingw32msvc \
CXXFLAGS="-mthreads -I/usr/local/i586-mingw32msvc/include" \
LDFLAGS=" -mthreads -L/usr/local/i586-mingw32msvc/lib" \
LIBS="-lcrypto -lws2_32 -lgdi32"
[..]
Regular expressions: yes
Large files:         no
Berkeley DB:         no
Readline:            no
Extended attributes: no

[check that g++ is set correctly, for instance in lib/win32/Makefile]

$ make
[..]
mkdir -p parcels/boxbackup-trunk_2463M-backup-server-mingw32msvc
cp -p docs/man/raidfile.conf.5.gz
parcels/boxbackup-trunk_2463M-backup-server-mingw32msvc
test -d parcels/boxbackup-trunk_2463M-backup-server-mingw32msvc || mkdir
parcels/boxbackup-trunk_2463M-backup-server-mingw32msvc
(cd parcels; tar cf - boxbackup-trunk_2463M-backup-server-mingw32msvc |
gzip -9 - > boxbackup-trunk_2463M-backup-server-mingw32msvc.tgz )



Starting it on windows seems to work, but once the certificates are
configured, the applications crash

> bbackupquery.exe -v
NOTICE:  Box Backup Query Tool vtrunk_2463M, (c) Ben Summers and
contributors 2003-2008
INFO:    Using configuration file
D:\install\boxbackup\cli.2463\bbackupd.conf
[boom]


> bbackupd.exe
WARNING:
==============================================================================
SECURITY WARNING: This platform cannot check the credentials of connections
to
the command socket. This is a potential DoS security problem.
Remove the CommandSocket directive from the bbackupd.conf file if
bbackupctl
is not used.
==============================================================================

NOTICE:  Starting daemon, version: trunk_2463M
NOTICE:  Using configuration file:
D:\install\boxbackup\cli.2463\bbackupd.conf
[boom]