L.s.

For those of you that want to build Microsoft Windows binaries on
Debian stable: Here are some patches that enable cross-compiling of Qt
5 (both libraries and examples) using mingw that comes bundled with
Debian 6 (current stable).
The resulting binaries can be tested with wine on Debian 6.

Features:
* Support for old version of mingw (4.2.1)
* Out-of-tree build supported (with, for now, one minor exception)

Problems:
* Lots (and I do mean LOTS) of spurious warnings when compiling 1)
* Any support for pkg-config is untested and/or completely accidental

The "minor exception" when using out-of-tree-build concerns the
validators widget example: It does not compile because some generated
code looks for include files in the wrong place. Create symlinks in
the build directory to the "missing" sourcefiles to hack your way
around this (see attachment).

Please note that mingw 4.2.1 needs an additional constant in
"/usr/i586-mingw32msvc/include/winerror.h":
#define CO_E_NOT_SUPPORTED ((HRESULT)0x80004021L)

Tip for testing under wine: Copy the Qt dlls and example programs to the
same directory and create an empty "qt.conf" file there. Run with wine.
Serves two.

Cordially,

kb



1) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34749
From 6a40e5d10d3eece94c454b6ed7044a00f064c3ac Mon Sep 17 00:00:00 2001
From: kb <[email protected]>
Date: Tue, 1 May 2012 08:46:51 +0200
Subject: [PATCH 1/4] Include cctype header so calls to isdigit and toupper work.

When crosscompiling on Debian 6 (targeting MS Windows) the build
fails because isdigit and toupper are not available. Including cctype
fixes that.
Note: Aforementioned functions are used for some simple ASCII parsing,
      so I saw no need to include locale instead of cctype.
---
 src/plugins/platforms/windows/qwindowscontext.cpp  |    1 +
 .../platforms/windows/qwindowskeymapper.cpp        |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index c5b1dcc..51b73d1 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -67,6 +67,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <windowsx.h>
+#include <cctype>
 
 QT_BEGIN_NAMESPACE
 
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index 4b5e958..1eba4bd 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -48,6 +48,8 @@
 #include <QtGui/QWindowSystemInterface>
 #include <QtGui/QKeyEvent>
 
+#include <cctype>
+
 QT_BEGIN_NAMESPACE
 
 /*!
-- 
1.7.2.5


From 9c464cffb392eb3dd802ee43c25c28477959d586 Mon Sep 17 00:00:00 2001
From: kb <[email protected]>
Date: Tue, 1 May 2012 09:02:52 +0200
Subject: [PATCH 2/4] Remove capitalization when specifying include-libraries.

When crosscompiling on Debian 6 (targeting MS Windows) linking
fails because mingw is looking for non-existent include-libraries.
Using lowercase names solves this.
---
 src/plugins/platforms/windows/windows.pro    |    6 +++---
 src/plugins/printsupport/windows/windows.pro |    2 +-
 src/printsupport/kernel/kernel.pri           |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro
index 87bc724..a61eef4 100644
--- a/src/plugins/platforms/windows/windows.pro
+++ b/src/plugins/platforms/windows/windows.pro
@@ -9,11 +9,11 @@ INCLUDEPATH += ../../../3rdparty/harfbuzz/src
 QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
 
 # Note: OpenGL32 must precede Gdi32 as it overwrites some functions.
-LIBS *= -lOpenGL32 -lGdi32 -lUser32 -lOle32 -lWinspool -lImm32 -lWinmm  -lOleaut32
+LIBS *= -lopengl32 -lgdi32 -luser32 -lole32 -lwinspool -limm32 -lwinmm  -loleaut32
 win32-g++: LIBS *= -luuid
 # For the dialog helpers:
-LIBS *= -lshlwapi -lShell32
-LIBS *= -lAdvapi32
+LIBS *= -lshlwapi -lshell32
+LIBS *= -ladvapi32
 
 DEFINES *= QT_NO_CAST_FROM_ASCII
 
diff --git a/src/plugins/printsupport/windows/windows.pro b/src/plugins/printsupport/windows/windows.pro
index 97d90a6..3c5f22d 100644
--- a/src/plugins/printsupport/windows/windows.pro
+++ b/src/plugins/printsupport/windows/windows.pro
@@ -19,4 +19,4 @@ OTHER_FILES += windows.json
 
 target.path += $$[QT_INSTALL_PLUGINS]/printsupport
 INSTALLS += target
-LIBS += -lWinspool -lComdlg32
+LIBS += -lwinspool -lcomdlg32
diff --git a/src/printsupport/kernel/kernel.pri b/src/printsupport/kernel/kernel.pri
index d7c9f56..b4bfbc8 100644
--- a/src/printsupport/kernel/kernel.pri
+++ b/src/printsupport/kernel/kernel.pri
@@ -30,7 +30,7 @@ win32 {
                 $$PWD/qprintengine_win_p.h
         SOURCES += \
                 $$PWD/qprintengine_win.cpp
-        LIBS += -lWinspool -lComdlg32
+        LIBS += -lwinspool -lcomdlg32
 }
 
 mac|win32 {
-- 
1.7.2.5


From 4a1109d2afe71bf418d8181126d1768cc9bd37eb Mon Sep 17 00:00:00 2001
From: kb <[email protected]>
Date: Tue, 1 May 2012 11:13:28 +0200
Subject: [PATCH 3/4] Do not limit mingw mkspec to "win32-g++".

The Qt configure script and various qmake project files interpret
mkspecs with a win32-g++ prefix as needing special mingw treatment.
This patch corrects one instance of the too-specific "win32-g++"
qmake platform scope and broadens it to "win32-g++*" -- bringing
it in line with the rest of the Qt project files -- thus re-enabling
custom mkspecs for crosscompilation.
---
 src/plugins/platforms/windows/windows.pro |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro
index a61eef4..06d802a 100644
--- a/src/plugins/platforms/windows/windows.pro
+++ b/src/plugins/platforms/windows/windows.pro
@@ -10,7 +10,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforms
 
 # Note: OpenGL32 must precede Gdi32 as it overwrites some functions.
 LIBS *= -lopengl32 -lgdi32 -luser32 -lole32 -lwinspool -limm32 -lwinmm  -loleaut32
-win32-g++: LIBS *= -luuid
+win32-g++*: LIBS *= -luuid
 # For the dialog helpers:
 LIBS *= -lshlwapi -lshell32
 LIBS *= -ladvapi32
-- 
1.7.2.5


From a0cdc040c8c016ebabe0966aee0872c9405f9c42 Mon Sep 17 00:00:00 2001
From: kb <[email protected]>
Date: Tue, 1 May 2012 19:28:20 +0200
Subject: [PATCH 4/4] Do not redefine CO_E_NOT_SUPPORTED

Although older mingw versions do not define this constant the
variant provided by Qt introduces another problem: sometimes
_HRESULT_TYPEDEF_ is not defined either. This patch allows us
to at least provide a custom version of CO_E_NOT_SUPPORTED if
need be.
---
 .../platforms/windows/qtwindows_additional.h       |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/plugins/platforms/windows/qtwindows_additional.h b/src/plugins/platforms/windows/qtwindows_additional.h
index 3465d4a..3c7211c 100644
--- a/src/plugins/platforms/windows/qtwindows_additional.h
+++ b/src/plugins/platforms/windows/qtwindows_additional.h
@@ -65,7 +65,9 @@
 #    define COLOR_MENUBAR     30
 #    define CF_DIBV5 17
 
+#if !defined(CO_E_NOT_SUPPORTED)
 #define CO_E_NOT_SUPPORTED               _HRESULT_TYPEDEF_(0x80004021L)
+#endif
 
 #define IFMETHOD HRESULT STDMETHODCALLTYPE
 #define IFACEMETHODIMP STDMETHODIMP
-- 
1.7.2.5

Attachment: qmake.conf
Description: config/conf

/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation ([email protected])
**
** This file is part of the qmake spec of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef QPLATFORMDEFS_H
#define QPLATFORMDEFS_H

#ifdef UNICODE
#ifndef _UNICODE
#define _UNICODE
#endif
#endif

// Get Qt defines/settings

#include "qglobal.h"

#include <tchar.h>
#include <io.h>
#include <direct.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <qt_windows.h>
#include <limits.h>

#if !defined(_WIN32_WINNT) || (_WIN32_WINNT-0 < 0x0500)
typedef enum {
    NameUnknown		  = 0, 
    NameFullyQualifiedDN  = 1, 
    NameSamCompatible	  = 2, 
    NameDisplay		  = 3, 
    NameUniqueId	  = 6, 
    NameCanonical	  = 7, 
    NameUserPrincipal	  = 8, 
    NameCanonicalEx	  = 9, 
    NameServicePrincipal  = 10, 
    NameDnsDomain	  = 12
} EXTENDED_NAME_FORMAT, *PEXTENDED_NAME_FORMAT;
#endif

#define Q_FS_FAT
#ifdef QT_LARGEFILE_SUPPORT
#define QT_STATBUF		struct _stati64		// non-ANSI defs
#define QT_STATBUF4TSTAT	struct _stati64		// non-ANSI defs
#define QT_STAT			::_stati64
#define QT_FSTAT		::_fstati64
#else
#define QT_STATBUF		struct _stat		// non-ANSI defs
#define QT_STATBUF4TSTAT	struct _stat		// non-ANSI defs
#define QT_STAT			::_stat
#define QT_FSTAT		::_fstat
#endif
#define QT_STAT_REG		_S_IFREG
#define QT_STAT_DIR		_S_IFDIR
#define QT_STAT_MASK		_S_IFMT
#if defined(_S_IFLNK)
#  define QT_STAT_LNK		_S_IFLNK
#endif
#define QT_FILENO		_fileno
#define QT_OPEN			::_open
#define QT_CLOSE		::_close
#ifdef QT_LARGEFILE_SUPPORT
#define QT_LSEEK		::_lseeki64
#ifndef UNICODE
#define QT_TSTAT		::_stati64
#else
#define QT_TSTAT		::_wstati64
#endif
#else
#define QT_LSEEK		::_lseek
#ifndef UNICODE
#define QT_TSTAT		::_stat
#else
#define QT_TSTAT		::_wstat
#endif
#endif
#define QT_READ			::_read
#define QT_WRITE		::_write
#define QT_ACCESS		::_access
#define QT_GETCWD		::_getcwd
#define QT_CHDIR		::_chdir
#define QT_MKDIR		::_mkdir
#define QT_RMDIR		::_rmdir
#define QT_OPEN_LARGEFILE       0
#define QT_OPEN_RDONLY		_O_RDONLY
#define QT_OPEN_WRONLY		_O_WRONLY
#define QT_OPEN_RDWR		_O_RDWR
#define QT_OPEN_CREAT		_O_CREAT
#define QT_OPEN_TRUNC		_O_TRUNC
#define QT_OPEN_APPEND		_O_APPEND
#if defined(O_TEXT)
# define QT_OPEN_TEXT		_O_TEXT
# define QT_OPEN_BINARY		_O_BINARY
#endif

#include "../common/c89/qplatformdefs.h"

#ifdef QT_LARGEFILE_SUPPORT
#undef QT_FSEEK
#undef QT_FTELL
#undef QT_OFF_T

#define QT_FSEEK                ::fseeko64
#define QT_FTELL                ::ftello64
#define QT_OFF_T                off64_t
#endif

#define QT_SIGNAL_ARGS		int

#define QT_VSNPRINTF		::_vsnprintf
#define QT_SNPRINTF		::_snprintf

# define F_OK	0
# define X_OK	1
# define W_OK	2
# define R_OK	4


#endif // QPLATFORMDEFS_H

Attachment: qt-inbuildFix
Description: Binary data

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to