After reading this article http://lukast.mediablog.sk/log/?p=155 I decided to use mingw on linux to compile windows applications. This means I can compile, test, debug and release directly from Linux.
I hacked this build script which will cross compile the application and even package it in a ZIP file. Note that I am using out of source builds for QMake (did you even know this is supported? wow...). Also note that the script will pull the needed DLLs automagically. Here is the script for you all internets to use and abuse:
#! /bin/sh
set -x
set -e
VERSION=0.1
PRO_FILE=blabla.pro
BUILD_DIR=mingw_build
DIST_DIR=blabla-$VERSION-win32
# clean up old shite
rm -fr $BUILD_DIR
mkdir $BUILD_DIR
cd $BUILD_DIR
# start building
QMAKESPEC=fedora-win32-cross qmake-qt4 QT_LIBINFIX=4 config=\"release\ quiet\" ../$PRO_FILE
#qmake-qt4 -spec fedora-win32-cross
make
DLLS=`i686-pc-mingw32-objdump -p release/*.exe | grep dll | awk '{print $3}'`
for i in $DLLS mingwm10.dll ; do
f=/usr/i686-pc-mingw32/sys-root/mingw/bin/$i
if [ ! -f $f ]; then continue; fi
cp -av $f release
done
mkdir -p $DIST_DIR
mv release/*.exe $DIST_DIR
mv release/*.dll $DIST_DIR
zip -r ../$DIST_DIR.zip $DIST_DIR
The compiled binary works on the Windows7 machine I tested. Now to the questions:
- When I execute the application on Windows, the theme is not the Windows7 theme. I assume I am missing a style module, I am not really sure yet.
- The application gets a console window for some reason.
The second point (the console window) is critical. How can I remove this background window? Please note that the extra config lines are not working for me, what am I missing there?
Edit 1 (planning a few):
The compilation line is:
i686-pc-mingw32-g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -o release/font_export.exe object_script.font_export.Release -L"/usr/i686-pc-mingw32/sys-root/mingw/lib" -lQtGui4 -lQtCore4
The -subsystem,windows
switch is added only when "CONFIG+=windows" and this is ignored in other OSes. My guess is that the MinGW port of Qt is getting confused "I am running on Linux, I need to ignore the windows/console configuration". This means I need to edit the corresponding qmake.spec file. arhg... I hate bugs. I still need to verify that this fixes the problem....