source: box/trunk/docs/api-notes/win32_build_on_linux_using_mingw.txt @ 2478

Revision 2478, 3.3 KB checked in by chris, 3 years ago (diff)

Rearrangement of api-notes directory.

  • Property svn:eol-style set to native
Line 
1How to build Box Backup for Windows (Native) on Linux using MinGW
2By Chris Wilson, 2005-12-07
3
4Install the MinGW cross-compiler for Windows:
5
6- Debian and Ubuntu users can "apt-get install mingw32"
7- Fedora and SuSE users can download RPM packages from
8  [http://mirzam.it.vu.nl/mingw/]
9
10You will need to know the prefix used by the cross-compiler executables.
11It will usually be something like "ix86-mingw32*-". All the binaries in the
12cross-compiler package will start with this prefix. The documentation below
13assumes that it is "i386-mingw32-". Adjust to taste.
14
15You will also need to install Wine and the Linux kernel "binary formats"
16(binfmt) support, so that you can run Windows executables on Linux,
17otherwise the configure scripts will not work properly with a cross-compiler.
18On Ubuntu, run:
19
20        apt-get install wine binfmt-support
21        /etc/init.d/binfmt-support start
22
23Start by downloading Zlib from [http://www.zlib.net/], unpack and enter
24source directory:
25
26        export CC=i386-mingw32-gcc
27        export AR="i386-mingw32-ar rc"
28        export RANLIB="i386-mingw32-ranlib"
29        ./configure
30        make
31        make install prefix=/usr/local/i386-mingw32
32
33Download OpenSSL 0.9.8b from
34[http://www.openssl.org/source/openssl-0.9.8b.tar.gz]
35
36Unpack and configure:
37
38        tar xzvf openssl-0.9.8b.tar.gz
39        cd openssl-0.9.8b
40        ./Configure --prefix=/usr/local/i386-mingw32 mingw
41        make makefile.one
42        wget http://www.boxbackup.org/svn/box/chris/win32/support/openssl-0.9.8b-mingw-cross.patch
43        patch -p1 < openssl-0.9.8b-mingw-cross.patch
44        make -f makefile.one
45        make -f makefile.one install
46
47Download PCRE from
48[http://prdownloads.sourceforge.net/pcre/pcre-6.3.tar.bz2?download]
49
50Unpack:
51
52        tar xjvf pcre-6.3.tar.bz2
53        cd pcre-6.3
54
55Configure and make:
56
57        export AR=i386-mingw32-ar
58        ./configure --host=i386-mingw32 --prefix=/usr/local/i386-mingw32/
59        make winshared
60
61If you get this error:
62
63        ./dftables.exe pcre_chartables.c
64        /bin/bash: ./dftables.exe: cannot execute binary file
65        make: *** [pcre_chartables.c] Error 126
66
67then run:
68
69        wine ./dftables.exe pcre_chartables.c
70        make winshared
71
72to complete the build. Finally:
73
74        cp .libs/libpcre.a /usr/local/i386-pc-mingw32/lib
75        cp .libs/libpcreposix.a /usr/local/i386-pc-mingw32/lib
76        cp pcreposix.h /usr/local/i386-pc-mingw32/include
77
78You will need to find a copy of mingwm10.dll that matches your cross-compiler.
79Most MinGW distributions should come with it. On Debian and Ubuntu, for some
80bizarre reason, you'll find it compressed as
81/usr/share/doc/mingw32-runtime/mingwm10.dll.gz, in which case you'll
82have to un-gzip it with "gzip -d". Copy it to a known location, e.g.
83/usr/local/i386-mingw32/bin.
84
85Download and extract Box Backup, and change into the base directory,
86e.g. boxbackup-0.11rc2. Change the path to mingwm10.dll in parcels.txt to
87match where you found or installed it.
88
89Now configure Box with:
90
91        ./configure --host=i386-mingw32 \
92                CXXFLAGS="-mthreads -I/usr/local/i386-mingw32/include" \
93                LDFLAGS=" -mthreads -L/usr/local/i386-mingw32/lib" \
94                LIBS="-lcrypto -lws2_32 -lgdi32"
95        make
96
97or, if that fails, try this:
98
99        export CXX="i386-mingw32-g++"
100        export AR=i386-mingw32-ar
101        export RANLIB=i386-mingw32-ranlib
102        export CFLAGS="-mthreads"
103        export CXXFLAGS="-mthreads"
104        export LDFLAGS="-mthreads"
105        export LIBS="-lcrypto -lws2_32 -lgdi32"
106        (if you don't have a "configure" file, run "./bootstrap")
107        ./configure --target=i386-mingw32
108        make CXX="$CXX" AR="$AR" RANLIB="$RANLIB" WINDRES="i386-mingw32-windres"
Note: See TracBrowser for help on using the repository browser.