cross compile QT4 program for windows on ubuntu dapper

1、首先安装基础程序:
sudo wine mingw32 mingw32-binutils mingw32-runtime
2、安装QT4支持(LINUX下的支持):
sudo apt-get install libqt4-core libqt4-gui libqt4-qt3support libqt4-sql libqt4-debug-dev libqt4-dev
3、下载QT4 for win程序:
wget http://wftp.tu-chemnitz.de/pub/Qt/qt/source/qt-win-opensource-4.1.2-mingw.exe
4、安装:
wine qt-win-opensource-4.1.2-mingw.exe
中间会提示找不到MINGW32的位置,没关系,可以直接跳过。
5、修改specs文件
sudo cp -Rf /usr/share/qt4/mkspecs/win32-g++ /usr/share/qt4/mkspecs/win32-x-g++
sudo nano /usr/share/qt4/mkspecs/win32-x-g++/qmake.conf
把和下面相关的内容都进行修改:

QMAKE_CXX = i586-mingw32msvc-g++

QMAKE_INCDIR = /usr/i586-mingw32msvc/include/
QMAKE_INCDIR_QT = /usr/local/qt4-w32/4.1.2/include
QMAKE_LIBDIR_QT = /usr/local/qt4-w32/4.1.2/lib

QMAKE_LINK = i586-mingw32msvc-g++

# ne pas oublier le -mwindows ici
QMAKE_LFLAGS = -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mwindows

#isEqual(MINGW_IN_SHELL, 1) {
QMAKE_DIR_SEP = /
QMAKE_COPY = cp
QMAKE_COPY_DIR = cp -r
QMAKE_MOVE = mv
QMAKE_DEL_FILE = rm -f
QMAKE_MKDIR = mkdir -p
QMAKE_DEL_DIR = rm -rf
#} else {
# QMAKE_COPY = cp
# QMAKE_COPY_DIR = cp -r
# QMAKE_MOVE = mv
# QMAKE_DEL_FILE = rm -f
# QMAKE_MKDIR = mkdir -p
# QMAKE_DEL_DIR = rm -rf
#}

# Enlever les .exe et rajouter -qt4
QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc-qt4
QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic-qt4

# Je n’ai pas trouvé d’équivalent de ce fichier, j’ai quand meme enlevé le .exe
QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc

QMAKE_RC = i586-mingw32msvc-windres

QMAKE_STRIP = i586-mingw32msvc-strip

6、QT4的跨平台编译支持就完成了,以后可以这样编译WINDOWS程序:
qmake-qt4 -project
qmake-qt4 -spec win32-x-g++
make


已发布

分类

,

来自

评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注