(M cross environment) is a Makefile that compiles a cross compiler and cross compiles many free libraries such as SDL and Qt.
apt-get install autoconf automake bash bison bzip2 \
cmake flex gettext git g++ intltool \
libffi-dev libtool libtool-bin libltdl-dev libssl-dev \
libxml-parser-perl make openssl patch perl \
pkg-config scons sed unzip wget xz-utils texinfo
# On 64-bit Debian, install also:
apt-get install g++-multilib libc6-dev-i386
make[3]: Leaving directory `/home/king/bino/po'
*** error: gettext infrastructure mismatch: using a Makefile.in.in from
gettext version 0.19 but the autoconf macros are from gettext version 0.18
$ cd /path/to
$ git clone -b master https://github.com/mxe/mxe.git
$ cd mxe
$ make gettext pthreads ffmpeg libass openal glew qt nsis
# 将mxe所有bin目录都加入PATH,而不止下面的mxe/usr/bin/
$ export PATH="/path/to/mxe/usr/bin:$PATH"
make --jobs=4 --keep-going
make MXE_TARGETS='i686-w64-mingw32.shared'
MXE_TRIPLETS := i686-w64-mingw32 x86_64-w64-mingw32
MXE_LIB_TYPES := shared
MXE_TARGET_LIST := $(foreach TRIPLET,$(MXE_TRIPLETS),\
$(addprefix $(TRIPLET).,$(MXE_LIB_TYPES)))
MXE_TARGETS := i686-w64-mingw32.shared
root@kingqiu:/home/king/bino# ls -l /home/king/mxe/usr/
total 28
drwxr-xr-x 2 root root 4096 Dec 9 14:32 bin
drwxr-xr-x 11 root root 4096 Dec 9 13:11 i686-w64-mingw32.static
$ cd /path/to/bino
$ autoreconf -i
$ ./configure --host=i686-w64-mingw32.static --build=`build-aux/config.guess` --target=i686-w64-mingw32.static
$ make
#!/bin/bash
export PKG_CONFIG_PATH=/home/king/mxe/usr/i686-w64-mingw32.static/lib/pkgconfig/
# mxe编译出来的都是静态库,所以这里使用static链接
# 手动添加的-L是为了指定第三方库(非qt)的库路径
i686-w64-mingw32-g++ -o3 -static main.cpp \
-L/home/king/mxe/usr/i686-w64-mingw32.static/lib/ \
`i686-w64-mingw32-pkg-config --libs --cflags --static QtGui`
#include <qapplication.h>
#include <qlabel.h>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
return app.exec();
}