MRW
http://piratenpartei.ch

Piratenpartei Zürich
PC 85-112704-0

Der Politnetz Auftritt von Marc Wäckerlin Im Politnetz unterstützen

CrossCompile Qt for Windows MinGW on Linux

Tested with Qt 4.7.1.

  1. Patch MinGW (know Problem with Debian package)
  2. Patch and compile Qt

Patch MinGW

If get the fopllowing errr message during compile:

/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libstdc++.a(stubs.o):(.text+0x160): multiple definition of `_powf'
./.obj/debug-shared/SVGLength.o:SVGLength.cpp:(.text$powf[_powf]+0x0): first defined here

Then powf ist double-defined and should be removed from the stdc++-library.

Run once after installing or upgrading the MinGW Debian / Ubuntu packages:

sudo i586-mingw32msvc-ar -d /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libstdc++.a stubs.o

Patch Qt

Get and unpack qt-everywhere-opensource-src-4.7.1 from http://qt.nokia.com

diff -ru qt-everywhere-opensource-src-4.7.1//mkspecs/win32-g++/qmake.conf qt-everywhere-opensource-src-4.7.1-win32//mkspecs/win32-g++/qmake.conf
--- qt-everywhere-opensource-src-4.7.1//mkspecs/win32-g++/qmake.conf	2011-02-07 10:46:01.395271865 +0100
+++ qt-everywhere-opensource-src-4.7.1-win32//mkspecs/win32-g++/qmake.conf	2011-02-10 09:58:01.942577519 +0100
@@ -6,7 +6,8 @@
 
 MAKEFILE_GENERATOR	= MINGW
 TEMPLATE		= app
-CONFIG			+= qt warn_on release link_prl copy_dir_files debug_and_release debug_and_release_target precompile_header
+CONFIG			+= qt warn_off release link_prl copy_dir_files precompile_header
+CONFIG                  += rtti exceptions
 QT			+= core gui
 DEFINES			+= UNICODE QT_LARGEFILE_SUPPORT
 QMAKE_COMPILER_DEFINES  += __GNUC__ WIN32
@@ -14,7 +15,7 @@
 QMAKE_EXT_OBJ           = .o
 QMAKE_EXT_RES           = _res.o
 
-QMAKE_CC		= gcc
+QMAKE_CC		= i586-mingw32msvc-gcc
 QMAKE_LEX		= flex
 QMAKE_LEXFLAGS		=
 QMAKE_YACC		= byacc
@@ -27,7 +28,7 @@
 QMAKE_CFLAGS_DEBUG	= -g
 QMAKE_CFLAGS_YACC	= -Wno-unused -Wno-parentheses
 
-QMAKE_CXX		= g++
+QMAKE_CXX		= i586-mingw32msvc-g++
 QMAKE_CXXFLAGS		= $$QMAKE_CFLAGS
 QMAKE_CXXFLAGS_DEPS	= $$QMAKE_CFLAGS_DEPS
 QMAKE_CXXFLAGS_WARN_ON	= $$QMAKE_CFLAGS_WARN_ON
@@ -41,7 +42,10 @@
 QMAKE_CXXFLAGS_EXCEPTIONS_ON = -fexceptions -mthreads
 QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -fno-exceptions
 
-QMAKE_INCDIR		=
+#INCLUDEPATH             += /usr/i586-mingw32msvc/include
+#INCLUDEPATH             += /opt/local/i586-mingw32msvc/include
+QMAKE_INCDIR            = /opt/local/i586-mingw32msvc/include
+QMAKE_LIBDIR            = /opt/local/i586-mingw32msvc/lib
 QMAKE_INCDIR_QT		= $$[QT_INSTALL_HEADERS]
 QMAKE_LIBDIR_QT		= $$[QT_INSTALL_LIBS]
 
@@ -50,8 +54,8 @@
 QMAKE_RUN_CXX		= $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src
 QMAKE_RUN_CXX_IMP	= $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
 
-QMAKE_LINK		= g++
-QMAKE_LINK_C		= gcc
+QMAKE_LINK		= i586-mingw32msvc-g++
+QMAKE_LINK_C		= i586-mingw32msvc-gcc
 QMAKE_LFLAGS		= -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
 QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads -Wl
 QMAKE_LFLAGS_EXCEPTIONS_OFF =
@@ -76,32 +80,32 @@
     MINGW_IN_SHELL      = 1
 	QMAKE_DIR_SEP		= /
 	QMAKE_QMAKE		~= s,\\\\,/,
-	QMAKE_COPY		= cp
-	QMAKE_COPY_DIR		= xcopy /s /q /y /i
+	QMAKE_COPY		= cp -r
+	QMAKE_COPY_DIR		= cp -r
 	QMAKE_MOVE		= mv
 	QMAKE_DEL_FILE		= rm
-	QMAKE_MKDIR		= mkdir
+	QMAKE_MKDIR		= mkdir -p
 	QMAKE_DEL_DIR		= rmdir
     QMAKE_CHK_DIR_EXISTS = test -d
 } else {
-	QMAKE_COPY		= copy /y
-	QMAKE_COPY_DIR		= xcopy /s /q /y /i
-	QMAKE_MOVE		= move
-	QMAKE_DEL_FILE		= del
-	QMAKE_MKDIR		= mkdir
+	QMAKE_COPY		= cp -r
+	QMAKE_COPY_DIR		= cp -fr
+	QMAKE_MOVE		= mv
+	QMAKE_DEL_FILE		= rm -r
+	QMAKE_MKDIR		= mkdir -p
 	QMAKE_DEL_DIR		= rmdir
-    QMAKE_CHK_DIR_EXISTS	= if not exist
+    QMAKE_CHK_DIR_EXISTS	= test -d
 }
 
-QMAKE_MOC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe
-QMAKE_UIC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe
-QMAKE_IDC		= $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe
+QMAKE_MOC		= $$[QT_INSTALL_BINS]/moc
+QMAKE_UIC		= $$[QT_INSTALL_BINS]/uic
+QMAKE_IDC		= $$[QT_INSTALL_BINS]/idc
 
 QMAKE_IDL		= midl
-QMAKE_LIB		= ar -ru
-QMAKE_RC		= windres
+QMAKE_LIB		= i586-mingw32msvc-ar -ru
+QMAKE_RC		= i586-mingw32msvc-windres
 QMAKE_ZIP		= zip -r -9
 
-QMAKE_STRIP		= strip
+QMAKE_STRIP		= i586-mingw32msvc-strip
 QMAKE_STRIPFLAGS_LIB 	+= --strip-unneeded
 load(qt_config)
diff -ru qt-everywhere-opensource-src-4.7.1//src/corelib/codecs/codecs.pri qt-everywhere-opensource-src-4.7.1-win32//src/corelib/codecs/codecs.pri
--- qt-everywhere-opensource-src-4.7.1//src/corelib/codecs/codecs.pri	2011-02-07 10:48:52.396759040 +0100
+++ qt-everywhere-opensource-src-4.7.1-win32//src/corelib/codecs/codecs.pri	2011-02-07 10:53:54.182322572 +0100
@@ -19,7 +19,7 @@
 	codecs/qutfcodec.cpp \
 	codecs/qtextcodecplugin.cpp
 
-unix {
+#unix {
 	SOURCES += codecs/qfontlaocodec.cpp
 
         contains(QT_CONFIG,iconv) {
@@ -55,5 +55,5 @@
                         ../plugins/codecs/tw/qbig5codec.cpp \
                         ../plugins/codecs/jp/qfontjpcodec.cpp
         }
-}
+#}
 symbian:LIBS += -lcharconv
diff -ru qt-everywhere-opensource-src-4.7.1//src/corelib/tools/qlocale.cpp qt-everywhere-opensource-src-4.7.1-win32//src/corelib/tools/qlocale.cpp
--- qt-everywhere-opensource-src-4.7.1//src/corelib/tools/qlocale.cpp	2011-02-07 10:48:53.546970826 +0100
+++ qt-everywhere-opensource-src-4.7.1-win32//src/corelib/tools/qlocale.cpp	2011-02-07 10:55:03.155020600 +0100
@@ -6624,18 +6624,18 @@
 {
     // Some values of the floating-point control word can cause _qdtoa to crash with an underflow.
     // We set a safe value here.
-#ifdef Q_OS_WIN
-    _clear87();
-    unsigned int oldbits = _control87(0, 0);
-#ifndef MCW_EM
-#    ifdef _MCW_EM
-#        define MCW_EM _MCW_EM
-#    else
-#        define MCW_EM 0x0008001F
-#    endif
-#endif
-    _control87(MCW_EM, MCW_EM);
-#endif
+// #ifdef Q_OS_WIN
+//     _clear87();
+//     unsigned int oldbits = _control87(0, 0);
+// #ifndef MCW_EM
+// #    ifdef _MCW_EM
+// #        define MCW_EM _MCW_EM
+// #    else
+// #        define MCW_EM 0x0008001F
+// #    endif
+// #endif
+//     _control87(MCW_EM, MCW_EM);
+// #endif
 
 #if defined(Q_OS_LINUX) && !defined(__UCLIBC__)
     fenv_t envp;
@@ -6644,14 +6644,14 @@
 
     char *s = _qdtoa(d, mode, ndigits, decpt, sign, rve, resultp);
 
-#ifdef Q_OS_WIN
-    _clear87();
-#ifndef _M_X64
-    _control87(oldbits, 0xFFFFF);
-#else
-    _control87(oldbits, _MCW_EM|_MCW_DN|_MCW_RC);
-#endif //_M_X64
-#endif //Q_OS_WIN
+// #ifdef Q_OS_WIN
+//     _clear87();
+// #ifndef _M_X64
+//     _control87(oldbits, 0xFFFFF);
+// #else
+//     _control87(oldbits, _MCW_EM|_MCW_DN|_MCW_RC);
+// #endif //_M_X64
+// #endif //Q_OS_WIN
 
 #if defined(Q_OS_LINUX) && !defined(__UCLIBC__)
     fesetenv(&envp);

Configure and Compile Qt

(echo yes | \
  ./configure -xplatform win32-g++ \
              -prefix /usr/local/trolltech/qt-mingw32 \
              -opensource \
              -no-phonon \
              -nomake examples \
              -nomake demos \
              -nomake docs \
              -nomake tools \
              -no-qt3support \
              -little-endian \
              -host-little-endian \
              -openssl \
              -system-zlib \
              -release)
make
sudo make install