发布MinGW QP 4.4.3-4,集成官方与TDM优点,交叉编译
官方4.4.0的缺点:
1. 头文件不能下断点;
2. 跨模块(DLL)不能catch exception调试
官方4.4.0的优点:
1. 对dw-2异常处理做了完善
2. 对Windows平台的SEH处理进行了完善
MinGW TDM 4.4.1版本的优点:
1. 头文件可以下断点
2. 可以跨模块(DLL)catch exception调试
3. 支持大文件
4. 支持-std=c++0x选项,修正__STRICT_ANSI__后的编译错误
5. stack扩充到32MB
6. 其他,我解释不了的修正
MinGW TDM 4.4.1版本的缺点:
1. 官方版本的优点它没有
另,TDM和官方都有的缺点是:版本更新比较落后,目前GCC已经发布4.4.3了...
且,TDM和官方版本都在cygwin模拟环境下编译,需要针对编译环境打补丁。
为了集成这两个版本的优点,克服他们的缺点,我有了在Linux平台交叉编译4.4.3的想法,并且集成官方和TDM的所有优点,克服他们的所有缺点!
MinGW QP版本的优点:
1. 官方4.4.0的所有优点
2. TDM4.4.1版本的所有优点
MinGW QP版本的缺点:
不详,有待实践检验。欢迎使用,本人已用此编译器编译了wxWidgets2.8.10、Qt4.6.2、Code::Blocks、boost1.4.2,经测试无误,所有优点集成成功后才发布。
完整版,集成了mingw32-4.4.3-4-all cross build with archlinux (binutils-2.20.1-2,gdb-7.0.50,make-3.81,mingwrt-3.18,w32api-3.14,pthreads2.8,iconv_1.13.1,解压后即可使用。
下载地址:http://qp-gcc.googlecode.com/files/mingw32-4.4.3-4-all.7z
仅gcc_g++编译器:http://qp-gcc.googlecode.com/files/gcc_g%2B%2B-4.4.3-4.7z
附上我探索15天的交叉编译方法:
交叉编译核心参数解释:
--build = 软件在什么平台下编译
--host = 软件在什么平台下运行
--target = 软件为什么平台服务(仅限开发工具链)
host = 后面的参数是四个部分:
架构-厂商-内核-标准库
例如 arm-generic-linux-gnu 表示 arm 架构,generic 厂商,linux内核,gnu glibc 标准库。
交叉编译器与target一致,比如去掉前面的i486-前缀,可以通过链接来实现,也可以自己编译。
cd /usr/binsufor files in i486-mingw32-*; do ln -s $files ${files:5}; doneexitDIR=/home/loaden/AUR/mingw32ABI=32 ../../src/gmp-5.0.1/configure \ --host=mingw32 \ --target=mingw32 \ --build=i686-pc-linux-gnu \ --enable-cxx \ --disable-static \ --enable-sharedmake && make install prefix=$DIR/gmp && mingw32-strip $DIR/gmp/bin/*
DIR=/home/loaden/AUR/mingw32../../src/mpfr-2.4.2/configure \ --host=mingw32 \ --target=mingw32 \ --build=i686-pc-linux-gnu \ --with-gmp=$DIR/gmp \ --disable-static \ --enable-sharedmake && make install prefix=$DIR/mpfr && mingw32-strip $DIR/mpfr/bin/*
# 给GCC源码打上补丁(在源码目录下执行)for files in ../patches/gcc*; do patch -p0 < $files; done# 在/mingw内建立链接(在编译目录下执行:可拷贝下列命令后同时执行)sudo mkdir /mingwsudo ln -s /usr/mingw32/include/ /mingw/includesudo ln -s /usr/mingw32/lib/ /mingw/lib# 定义变量DIR=/home/loaden/AUR/mingw32GCC_VER=4.4.3# 为libgomp配置pthread路径mkdir -p ./mingw32/libgompecho \CFLAGS=\"-I$DIR/pthreads/include -O2 -mthreads -D__USE_MINGW_ACCESS\"$'\n'\LDFLAGS=\"-L$DIR/pthreads/lib\"$'\n'\> ./mingw32/libgomp/config.cache# 导出环境变量export C_INCLUDE_PATH="$DIR/pthreads/include"export CPLUS_INCLUDE_PATH="$DIR/pthreads/include"export LIBRARY_PATH="$DIR/pthreads/lib"export LD_LIBRARY_PATH="$DIR/pthreads/bin"export CFLAGS="-I$DIR/pthreads/include -O2 -D__USE_MINGW_ACCESS"export BOOT_CFLAGS="-O2 -D__USE_MINGW_ACCESS"export CFLAGS_FOR_TARGET="-O2 -D__USE_MINGW_ACCESS"export CXXFLAGS="-I$DIR/pthreads/include -mthreads -O2 -D__USE_MINGW_ACCESS"export BOOT_CXXFLAGS="-mthreads -O2 -D__USE_MINGW_ACCESS"export CXXFLAGS_FOR_TARGET="-mthreads -O2 -D__USE_MINGW_ACCESS"export LDFLAGS="-s" BOOT_LDFLAGS="-s"export LDFLAGS_FOR_TARGET="-L$DIR/pthreads/lib -s"# 配置../../src/gcc-$GCC_VER/configure \ --prefix=/mingw \ --host=mingw32 \ --target=mingw32 \ --build=i686-pc-linux-gnu \ --enable-languages=c,c++ \ --enable-cxx-flags='-fno-function-sections -fno-data-sections' \ --enable-fully-dynamic-string \ --enable-version-specific-runtime-libs \ --enable-threads=win32 \ --enable-libgomp \ --disable-nls \ --disable-libstdcxx-pch \ --disable-win32-registry \ --disable-sjlj-exceptions \ --with-dwarf2 \ --with-gmp=$DIR/gmp \ --with-mpfr=$DIR/mpfr \ --with-pkgversion='QP MinGW32' \ --with-bugurl=http://www.qpsoft.com/blog/guestbook.phpmake# -Wl,...: 告诉GCC传递后面的选项给liker链接器# 加入--stack=0x2000000把stack设为32MB,解决可能的stack overflow。rm -f gcc/cc1.exe gcc/cc1plus.exemake install DESTDIR=$DIR LDFLAGS="-s -Wl,--stack=0x2000000"