views:

379

answers:

2

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

A: 

You might be able to remove it by including -Wl,-subsystem,windows. This article shows how, but you want to replace -mwindows with -Wl,-subsystem,windows to avoid using a depricated feature of gcc.

e8johan
A: 

I suspect that your theme problem is te result of a missing application manifest

The reason that your app gets a console is simple. Windows apps come in two flavors, Console and GUI. The difference is a bit in the PE header of the EXE. GCC's default is to generate a Console app, and e8johan explains how to change that (-Wl,-subsystem,windows). There's also some fooling around with entry points (GUI's are expected to use WinMain(), and console apps main()) but MinGW should take care of that

MSalters