[Box Backup] Cross-compilation with i586-mingw32msvc under Ubuntu Hardy

Achim boxbackup@boxbackup.org
Mon, 23 Mar 2009 16:26:04 +0100


Hello Chris:

On Sun, 22 Mar 2009 10:35:16 +0000 (GMT), Chris Wilson <chris@qwirx.com>
wrote:

> You're right that libpcre.a needs to be copied from the PCRE build 
> directory as well as libpcreposix.a. However, even doing so is not
enough, 
> as long as you still have regex.h in /usr/local/i586-mingw32msvc/include,

> as the libraries will not be detected and used.
> 
> If you remove /usr/local/i586-mingw32msvc/include/regex.h, copy libpcre.a

> and configure Box Backup again, that should hopefully fix the 
> cross-compile.

Below are the detailed steps, but with 2463 the build process fails again
due to wrong CXX flags, and WINDRES has to be set manually:

$ make WINDRES="i586-mingw32msvc-windres"
test -d parcels/boxbackup-chris_general_2463M-backup-client-mingw32msvc ||
mkdir parcels/boxbackup-chris_general_2463M-backup-client-mingw32msvc
(cd bin/bbackupd; make RELEASE=1)
make[1]: Entering directory `/usr/src/boxi/trunk.2463/bin/bbackupd'
make[2]: Entering directory `/usr/src/boxi/trunk.2463/lib/win32'
[WINDRES] messages.rc
[AR]      ../../release/lib/win32/win32.a
ar: creating ../../release/lib/win32/win32.a
[RANLIB]  ../../release/lib/win32/win32.a
make[2]: Leaving directory `/usr/src/boxi/trunk.2463/lib/win32'
make[2]: Entering directory `/usr/src/boxi/trunk.2463/lib/common'
[CXX]     ReadLoggingStream.cpp
In file included from BoxPlatform.h:38,
                 from Box.h:18,
                 from ReadLoggingStream.cpp:10:
/usr/include/sys/types.h:67: error: multiple types in one declaration
/usr/include/sys/types.h:67: error: declaration does not declare anything
/usr/include/sys/types.h:82: error: multiple types in one declaration
/usr/include/sys/types.h:82: error: declaration does not declare anything
make[2]: *** [../../release/lib/common/ReadLoggingStream.o] Error 1
make[2]: Leaving directory `/usr/src/boxi/trunk.2463/lib/common'
make[1]: *** [dep_modules] Error 2
make[1]: Leaving directory `/usr/src/boxi/trunk.2463/bin/bbackupd'
make: ***
[parcels/boxbackup-chris_general_2463M-backup-client-mingw32msvc.tgz] Error
2


$ cat /trunk.2463/lib/win32/Makefile | grep CXX
CXX = g++
CXXFLAGS = -DNDEBUG -O0 -g -Wall   -DBOX_VERSION="\"chris_general_2463\""
CXXFLAGS = -g -Wall   -DBOX_VERSION="\"chris_general_2463\""
_CXX     = $(if $(V),$(CXX),     @ echo "[CXX]     $<" && $(CXX))
_LINK    = $(if $(V),$(CXX),     @ echo "[LINK]    $@" && $(CXX))
        $(_CXX) $(CXXFLAGS)  -mthreads
-I/usr/local/i586-mingw32msvc/include -Wall -c emu.cpp -o $(OUTDIR)/emu.o


which is probably wrong, because CXX should be i586-mingw32msvc-g++?

Once changed, make works (even though WINDRES still needs to be set)

$ make WINDRES="i586-mingw32msvc-windres"
[WINDRES] messages.rc
[AR]      ../../debug/lib/win32/win32.a
ar: creating ../../debug/lib/win32/win32.a
[RANLIB]  ../../debug/lib/win32/win32.a



---- snip ----
aptitude purge mingw32 mingw-zlib mingw32-binutils mingw32-runtime
rm -r /usr/local/i586-mingw32msvc


aptitude install mingw32 


tar xvzf zlib-1.2.3.tar.gz

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


$ ls -l /usr/local/i586-mingw32msvc/include
-rw-r--r-- 1 root root  9544 2009-03-23 15:42 zconf.h
-rw-r--r-- 1 root root 66188 2009-03-23 15:42 zlib.h




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
Building OpenSSL
[..]
./apps/ocsp.c: In function âocsp_mainâ:
./apps/ocsp.c:578: warning: function called through a non-compatible type
./apps/ocsp.c:578: note: if this code is reached, the program will abort
./apps/ocsp.c:679: warning: function called through a non-compatible type
./apps/ocsp.c:679: note: if this code is reached, the program will abort
./apps/ocsp.c:755: warning: function called through a non-compatible type
./apps/ocsp.c:755: note: if this code is reached, the program will abort
./apps/ocsp.c:780: warning: function called through a non-compatible type
./apps/ocsp.c:780: note: if this code is reached, the program will abort
./apps/ocsp.c: In function âdo_responderâ:
./apps/ocsp.c:1201: warning: function called through a non-compatible type
./apps/ocsp.c:1201: note: if this code is reached, the program will abort
./apps/ocsp.c: In function âsend_ocsp_responseâ:
./apps/ocsp.c:1223: warning: function called through a non-compatible type
./apps/ocsp.c:1223: note: if this code is reached, the program will abort

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




$ ls -l /usr/local/i586-mingw32msvc/include
drwxr-xr-x 2 root root  4096 2009-03-23 15:50 openssl
-rw-r--r-- 1 root root  9544 2009-03-23 15:42 zconf.h
-rw-r--r-- 1 root root 66188 2009-03-23 15:42 zlib.h



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


$ ls -l /usr/local/i586-mingw32msvc/include
drwxr-xr-x 2 root root  4096 2009-03-23 15:50 openssl
-rw-r--r-- 1 root root  4086 2009-03-23 15:51 pcreposix.h
-rw-r--r-- 1 root root  9544 2009-03-23 15:42 zconf.h
-rw-r--r-- 1 root root 66188 2009-03-23 15:42 zlib.h



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


 tar xvzf boxbackup-0.11rc2.tgz

Change the path to mingwm10.dll in parcels.txt to match where you found or
installed it.

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

make WINDRES="i586-mingw32msvc-windres"

test -d parcels/boxbackup-0.11rc2-backup-client-mingw32msvc || mkdir
parcels/boxbackup-0.11rc2-backup-client-mingw32msvc
(cd bin/bbackupd; make RELEASE=1)
make[1]: Entering directory `/usr/src/boxi/boxbackup-0.11rc2/bin/bbackupd'
make[2]: Entering directory `/usr/src/boxi/boxbackup-0.11rc2/lib/win32'
[WINDRES] messages.rc
[AR]      ../../release/lib/win32/win32.a
i586-mingw32msvc-ar: creating ../../release/lib/win32/win32.a
[RANLIB]  ../../release/lib/win32/win32.a
make[2]: Leaving directory `/usr/src/boxi/boxbackup-0.11rc2/lib/win32'
make[2]: Entering directory `/usr/src/boxi/boxbackup-0.11rc2/lib/common'
[CXX]     BoxException.cpp
In file included from Box.h:57,
                 from BoxException.cpp:49:
BoxPlatform.h:217:4: error: #error No way to get file descriptor from DIR
structure
make[2]: *** [../../release/lib/common/BoxException.o] Error 1
make[2]: Leaving directory `/usr/src/boxi/boxbackup-0.11rc2/lib/common'
make[1]: *** [dep_modules] Error 2
make[1]: Leaving directory `/usr/src/boxi/boxbackup-0.11rc2/bin/bbackupd'
make: *** [parcels/boxbackup-0.11rc2-backup-client-mingw32msvc.tgz] Error 2




$ svn co http://www.boxbackup.org/svn/box/chris/general/ trunk.2463
Checked out revision 2463.

Change the path to mingwm10.dll in parcels.txt to match where you found or
installed it.
        script /usr/local/i586-mingw32msvc/bin/mingwm10.dll


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

$ make
test -d parcels/boxbackup-chris_general_2463M-backup-client-mingw32msvc ||
mkdir parcels/boxbackup-chris_general_2463M-backup-client-mingw32msvc
(cd bin/bbackupd; make RELEASE=1)
make[1]: Entering directory `/usr/src/boxi/trunk.2463/bin/bbackupd'
make[2]: Entering directory `/usr/src/boxi/trunk.2463/lib/win32'
[CXX]     emu.cpp
cc1plus: error: unrecognized command line option "-mthreads"
make[2]: *** [../../release/lib/win32/emu.o] Error 1
make[2]: Leaving directory `/usr/src/boxi/trunk.2463/lib/win32'
make[1]: *** [dep_modules] Error 2
make[1]: Leaving directory `/usr/src/boxi/trunk.2463/bin/bbackupd'
make: ***
[parcels/boxbackup-chris_general_2463M-backup-client-mingw32msvc.tgz] Error
2


$ make WINDRES="i586-mingw32msvc-windres"
test -d parcels/boxbackup-chris_general_2463M-backup-client-mingw32msvc ||
mkdir parcels/boxbackup-chris_general_2463M-backup-client-mingw32msvc
(cd bin/bbackupd; make RELEASE=1)
make[1]: Entering directory `/usr/src/boxi/trunk.2463/bin/bbackupd'
make[2]: Entering directory `/usr/src/boxi/trunk.2463/lib/win32'
[WINDRES] messages.rc
[AR]      ../../release/lib/win32/win32.a
ar: creating ../../release/lib/win32/win32.a
[RANLIB]  ../../release/lib/win32/win32.a
make[2]: Leaving directory `/usr/src/boxi/trunk.2463/lib/win32'
make[2]: Entering directory `/usr/src/boxi/trunk.2463/lib/common'
[CXX]     ReadLoggingStream.cpp
In file included from BoxPlatform.h:38,
                 from Box.h:18,
                 from ReadLoggingStream.cpp:10:
/usr/include/sys/types.h:67: error: multiple types in one declaration
/usr/include/sys/types.h:67: error: declaration does not declare anything
/usr/include/sys/types.h:82: error: multiple types in one declaration
/usr/include/sys/types.h:82: error: declaration does not declare anything
make[2]: *** [../../release/lib/common/ReadLoggingStream.o] Error 1
make[2]: Leaving directory `/usr/src/boxi/trunk.2463/lib/common'
make[1]: *** [dep_modules] Error 2
make[1]: Leaving directory `/usr/src/boxi/trunk.2463/bin/bbackupd'
make: ***
[parcels/boxbackup-chris_general_2463M-backup-client-mingw32msvc.tgz] Error
2


$ i586-mingw32msvc-gcc -v
Using built-in specs.
Target: i586-mingw32msvc
Configured with:
/build/buildd/mingw32-4.2.1.dfsg/build_dir/src/gcc-4.2.1-2-dfsg/configure
-v --prefix=/usr --target=i586-mingw32msvc --enable-languages=c,c++
--enable-threads --enable-sjlj-exceptions --disable-multilib
--enable-version-specific-runtime-libs
Thread model: win32
gcc version 4.2.1-sjlj (mingw32-2)


$ cat /trunk.2463/lib/win32/Makefile | grep CXX
CXX = g++
CXXFLAGS = -DNDEBUG -O0 -g -Wall   -DBOX_VERSION="\"chris_general_2463\""
CXXFLAGS = -g -Wall   -DBOX_VERSION="\"chris_general_2463\""
_CXX     = $(if $(V),$(CXX),     @ echo "[CXX]     $<" && $(CXX))
_LINK    = $(if $(V),$(CXX),     @ echo "[LINK]    $@" && $(CXX))
        $(_CXX) $(CXXFLAGS)  -mthreads
-I/usr/local/i586-mingw32msvc/include -Wall -c emu.cpp -o $(OUTDIR)/emu.o


which is probably wrong, because CXX should be i586-mingw32msvc-g++?

Once changed, make works (even though WINDRES still needs to be set)

$ make WINDRES="i586-mingw32msvc-windres"
[WINDRES] messages.rc
[AR]      ../../debug/lib/win32/win32.a
ar: creating ../../debug/lib/win32/win32.a
[RANLIB]  ../../debug/lib/win32/win32.a