Cross compilation Win32

From VLE

Jump to: navigation, search

Cross compilation Win32 x86

In this page, we describe how to build the Win32 version of VLE using a cross compilation system on GNU/Linux. This toolchain allow to launch build, launch unit test and build an installer for Windows XP, Vista, Seven 32 or 64 bits.

Configure the system

  • Project Mingw32 (Minimalist GNU win32 (cross) compiler) is a C/C++/Ada/Java compiler from the GNU GCC with Win32 target (Windows 2000, XP, Vista et 7). To install this compiler suite on Debian distribution or derivated (Ubuntu ou knoppix) :
sudo apt-get install mingw32 mingw32-binutils mingw32-runtime nsis
  • In the next step, we need to build the libraries Boost. You need to download the latest version of boost sources package and follow the commands:
# untar the boost sources
tar jxf boost_1_39_0.tar.bz2
 
# build the bjam program provided with Boost
./bootstrap.sh --without-icu
 
# build a cross compilation parameter file and update the version of Gcc (here 4.4)
echo "using gcc : 4.4 : i586-mingw32msvc-g++
        :
        <rc>i586-mingw32msvc-windres
        <archiver>i586-mingw32msvc-ar
;" > user-config.jam
 
# build boost and install them into the directory $PREFIX
./bjam toolset=gcc target-os=windows variant=release threading=multi threadapi=win32\
    link=shared runtime-link=shared --prefix=$PREFIX --user-config=user-config.jam -j 2\
    --without-mpi --without-python -sNO_BZIP2=1 -sNO_ZLIB=1 --layout=tagged install
  • VLE depends of XML, GUI, SVG libraries provided in binary package by Gtkmm. Download the gtkmm-win32 installer gtkmm-devel and follow the commands:
# Install the library using wine or any Win32 emulator
wine gtkmm-win32-devel-2.16.0-4.exe
 
# Copy all file into the $PREFIX directory (the same as Boost installation)
cp -r $HOME/.wine/.wine/drive_c/Program\ Files/gtkmm $PREFIX
  • Last, we need to get the file mingw10.dll provided with the package mingw32-runtime.
gunzip -c /usr/share/doc/mingw32-runtime/mingwm10.dll.gz > $PREFIX/bin/mingwm10.dll

Construction

La dernière étape est en réalité la plus simple puisque l'ensemble de la plate-forme est dorénavant compatible avec ce mode de compilation.

  • La construction nécessite un script cmake spécial pour définir l'utilisation des compilateurs et bibliothèques compatibles Win32 : Toolchain-mingw32.cmake à mettre dans le dossier $prefix/bin par exemple :
# Le nom de la plate-forme cible.
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_VERSION 1)
 
# Les variables qui définissent les compilateur à utiliser.
SET(CMAKE_C_COMPILER /usr/bin/i586-mingw32msvc-gcc)
SET(CMAKE_CXX_COMPILER /usr/bin/i586-mingw32msvc-c++)
SET(CMAKE_RC_COMPILER /usr/bin/i586-mingw32msvc-windres)
 
# Une variable qui définit les chemins où chercher les bibliothèques et
# autres fichiers d'entêtes pour la plate-forme cible. Le deuxième chemin
# est ici égal à la variable $prefix
SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc $prefix)
 
# Quelques définition de variables à passer au script de compilation Cmake.
SET(CMAKE_BUILD_TYPE RelWithDebInfo)
SET(Boost_ADDITIONAL_VERSIONS "1.41" "1.41.0")
SET(BOOST_ROOT           /home/goth/tmp/win32)
SET(BOOSTROOT            /home/goth/tmp/win32)
SET(BOOST_INCLUDEDIR     /home/goth/tmp/win32/include)
SET(BOOST_LIBRARYDIR     /home/goth/tmp/win32/lib)
SET(GTKMM_BASEPATH       /home/goth/tmp/win32)
SET(MINGW_BASEPATH       /home/goth/tmp/win32)
SET(Boost_COMPILER       "-mgw42")
 
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  • La dernière étape de cette procédure est de compiler la plate-forme et de créer le paquet associé.
# Téléchargement des sources de VLE.
git clone git://vle.git.sourceforge.net/gitroot/vle/vle
cd vle
mkdir build
cd build
pushd .
 
# Création d'une variable d'environnement pour forcer la recherche des fichiers pkg-config dans le bon chemin.
# À noter qu'il faudra peut être modifier tous les fichiers de ce répertoire pour avoir un chemin correct du 
# type : prefix=/home/quesnel/cross/win32
cd $prefix/lib/pkgconfig
sed -e 's/^prefix=.*$/prefix=\/home\/goth\/tmp\/win32/' -i *.pc
 
popd
export PKG_CONFIG_PATH=$prefix/lib/pkgconfig
 
# Création des scripts de compilation, compilation et création du paquet.
cmake -DCMAKE_TOOLCHAIN_FILE=$prefix/Toolchain-mingw32.cmake \
      -DWITH_TEST=OFF ..
 
# Compilation sur deux coeurs
make -j 2
 
# Création de l'auto-installateur
make package


This page was last modified on 25 July 2010, at 15:56. This page has been accessed 2,418 times.