From: Guus Sliepen Date: Tue, 26 Jun 2012 10:22:35 +0000 (+0200) Subject: Update cross-compiling examples. X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=7e9013f3810b5d012a3419c84732f605f051a1af;p=wiki Update cross-compiling examples. --- diff --git a/examples/cross-compiling-64-bit-windows-binary.mdwn b/examples/cross-compiling-64-bit-windows-binary.mdwn index cf4a9b5..f35ab4c 100644 --- a/examples/cross-compiling-64-bit-windows-binary.mdwn +++ b/examples/cross-compiling-64-bit-windows-binary.mdwn @@ -21,23 +21,16 @@ The idea is simple: There are only a few packages that need to be installed as root to get started: - sudo apt-get install gcc-mingw32 mingw64 git-core wget + sudo apt-get install mingw-w64 git-core wget sudo apt-get build-dep tinc Other Linux distributions may also have 64-bit MinGW packages, use their respective package management tools to install them. Debian installs the cross-compiler -in `/usr/amd64-mingw32msvc/`. Other distributions might install it in another +in `/usr/x86_64-w64-mingw32/`. Other distributions might install it in another directory however. Check in which directory -it is installed, and replace all occurences of `amd64-mingw32msvc` in this +it is installed, and replace all occurences of `x86_64-w64-mingw32` in this example with the correct name from your distribution. -At the time of writing, the gcc-mingw32 package contains the 64-bit compiler as -well, in the future this might be put into its own package. Also, a header file -is missing in the amd64-mingw32msvc include directory, a workaround is to -create a symlink to the otherwise identical 32-bit version of that header file: - - ln -s ../../i586-mingw32msvc/include/getopt.h /usr/amd64-mingw32msvc/include/getopt.h - ### Setting up the build directory and getting the sources We will create a directory called `mingw64/` in the home directory. We use @@ -46,9 +39,7 @@ apt-get and wget to get the required libraries necessary for tinc, and use mkdir $HOME/mingw64 cd $HOME/mingw64 - apt-get source liblzo2-dev zlib1g-dev - wget http://www.openssl.org/source/openssl-1.0.0.tar.gz - tar xzf openssl-1.0.0.tar.gz + apt-get source liblzo2-dev zlib1g-dev libssl-dev git clone git://tinc-vpn.org/tinc ### Making cross-compilation easy @@ -60,11 +51,12 @@ use the 64-bit MinGW version of GCC and binutils: mkdir $HOME/bin cat >$HOME/bin/mingw64 << EOF #!/bin/sh - export CC=amd64-mingw32msvc-gcc - export CXX=amd64-mingw32msvc-g++ - export CPP=amd64-mingw32msvc-cpp - export RANLIB=amd64-mingw32msvc-ranlib - export PATH="/usr/amd64-mingw32msvc/bin:$PATH" + PREFIX=x86_64-w64-mingw32 + export CC=$PREFIX-gcc + export CXX=$PREFIX-g++ + export CPP=$PREFIX-cpp + export RANLIB=$PREFIX-ranlib + export PATH="/usr/x86_64-w64-mingw32/bin:$PATH" exec "$@" EOF chmod u+x $HOME/bin/mingw64 @@ -85,8 +77,8 @@ time it is needed. Cross-compiling LZO is easy: - cd $HOME/mingw64/lzo2-2.03 - ./configure --host=amd64-mingw32msvc + cd $HOME/mingw64/lzo2-2.06 + ./configure --host=x86_64-w64-mingw32 make DESTDIR=$HOME/mingw64 make install @@ -98,7 +90,7 @@ create a symlink for the missing getopt.h file as mentioned above. Cross-compiling Zlib is also easy, but a plain `make` failed to compile the tests, so we only build the static library here: - cd $HOME/mingw64/zlib-1.2.3.3.dfsg + cd $HOME/mingw64/zlib-1.2.7.dfsg mingw64 ./configure mingw64 make libz.a DESTDIR=$HOME/mingw64 mingw64 make install @@ -111,7 +103,7 @@ Debian-specific patches that break cross-compiling a Windows binary. You need to undo those patches first. Do not use the `-j` option when compiling OpenSSL, it will break. - cd $HOME/mingw64/openssl-1.0.0 + cd $HOME/mingw64/openssl-1.0.1c quilt pop -a mingw64 ./Configure --openssldir=$HOME/mingw64/usr/local mingw64 mingw64 make @@ -126,5 +118,5 @@ this is not necessary. cd $HOME/mingw64/tinc autoreconf -fsi - ./configure --host=amd64-mingw32msvc --with-openssl=$HOME/mingw64/usr/local + ./configure --host=x86_64-w64-mingw32 --with-openssl=$HOME/mingw64/usr/local make diff --git a/examples/cross-compiling-windows-binary.mdwn b/examples/cross-compiling-windows-binary.mdwn index 5574306..3e3bd16 100644 --- a/examples/cross-compiling-windows-binary.mdwn +++ b/examples/cross-compiling-windows-binary.mdwn @@ -24,14 +24,14 @@ The idea is simple: There are only a few packages that need to be installed as root to get started: - sudo apt-get install mingw32 wine git-core + sudo apt-get install mingw-w64 wine git-core sudo apt-get build-dep tinc Other Linux distributions may also have MinGW packages, use their respective package management tools to install them. Debian installs the cross-compiler -in `/usr/i586-mingw32msvc/`. Other distributions might install it in another +in `/usr/i686-w64-mingw32/`. Other distributions might install it in another directory however, for example `/usr/i686-pc-mingw32/`. Check in which directory -it is installed, and replace all occurences of `i586-mingw32msvc` in this +it is installed, and replace all occurences of `i686-w64-mingw32` in this example with the correct name from your distribution. ### Setting up the build directory and getting the sources @@ -54,11 +54,12 @@ use the MinGW version of GCC and binutils: mkdir $HOME/bin cat >$HOME/bin/mingw << EOF #!/bin/sh - export CC=i586-mingw32msvc-gcc - export CXX=i586-mingw32msvc-g++ - export CPP=i586-mingw32msvc-cpp - export RANLIB=i586-mingw32msvc-ranlib - export PATH="/usr/i586-mingw32msvc/bin:$PATH" + PREFIX=i686-w64-mingw32 + export CC=$PREFIX-gcc + export CXX=$PREFIX-g++ + export CPP=$PREFIX-cpp + export RANLIB=$PREFIX-ranlib + export PATH="/usr/$PREFIX/bin:$PATH" exec "$@" EOF chmod u+x $HOME/bin/mingw @@ -79,8 +80,8 @@ time it is needed. Cross-compiling LZO is easy: - cd $HOME/mingw/lzo2-2.03 - ./configure --host=i586-mingw32msvc + cd $HOME/mingw/lzo2-2.06 + ./configure --host=i686-w64-mingw32 make DESTDIR=$HOME/mingw make install @@ -89,27 +90,17 @@ Cross-compiling LZO is easy: Cross-compiling Zlib is also easy, but a plain `make` failed to compile the tests, so we only build the static library here: - cd $HOME/mingw/zlib-1.2.3.3.dfsg + cd $HOME/mingw/zlib-1.2.7.dfsg mingw ./configure mingw make libz.a DESTDIR=$HOME/mingw mingw make install ### Compiling OpenSSL -OpenSSL is always a bit hard to compile, because they have their own -`Configure` script that needs some tweaking. There is also a small bug in -e_os2.h in OpenSSL 0.9.8 that breaks compilation with recent versions of GCC. -If you have this version of OpenSSL, then first download -this [[openssl-cross-compilation.diff]] to your home directory, then patch -OpenSSL: - - cd $HOME/mingw/openssl-0.9.8k - patch < $HOME/openssl-cross-compilation.diff - -With OpenSSL 1.0.0, this problem is no longer present. However, `apt-get source` will have applied +OpenSSL 1.0.0 and later is relatively easy. However, `apt-get source` will have applied Debian-specific patches that break cross-compiling a Windows binary. You need to undo those patches first: - cd $HOME/mingw/openssl-0.9.8k + cd $HOME/mingw/openssl-1.0.1c quilt pop -a Now you can compile OpenSSL. @@ -128,14 +119,14 @@ this is not necessary. cd $HOME/mingw/tinc autoreconf -fsi - ./configure --host=i586-mingw32msvc --with-openssl=$HOME/mingw/usr/local + ./configure --host=i686-w64-mingw32 --with-zlib=$HOME/mingw/usr/local make ### Testing tinc Since Wine was installed, you can execute the resulting binary even on Linux. -You cannot do much however, since tinc requires a TAP-Win32 device, which is -not available in Wine. Still, the following command should work: +Wine does not provide a TAP-Win32 device, but you can use the `DeviceType = dummy` option to test it without. +The following command should work in any case: $HOME/mingw/tinc/src/tincd.exe --help