64,642
社区成员
发帖
与我相关
我的任务
分享
cd /usr/bin
su
for files in i486-mingw32-*; do ln -s $files ${files:5}; done
exit
DIR=/home/loaden/AUR/mingw32
ABI=32 ../../src/gmp-5.0.1/configure \
--host=mingw32 \
--target=mingw32 \
--build=i686-pc-linux-gnu \
--enable-cxx \
--disable-static \
--enable-shared
make && 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-shared
make && make install prefix=$DIR/mpfr && mingw32-strip $DIR/mpfr/bin/*
# 给GCC源码打上补丁(在源码目录下执行)
for files in ../patches/gcc*; do patch -p0 < $files; done
# 在/mingw内建立链接(在编译目录下执行:可拷贝下列命令后同时执行)
sudo mkdir /mingw
sudo ln -s /usr/mingw32/include/ /mingw/include
sudo ln -s /usr/mingw32/lib/ /mingw/lib
# 定义变量
DIR=/home/loaden/AUR/mingw32
GCC_VER=4.4.3
# 为libgomp配置pthread路径
mkdir -p ./mingw32/libgomp
echo \
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.php
make
# -Wl,...: 告诉GCC传递后面的选项给liker链接器
# 加入--stack=0x2000000把stack设为32MB,解决可能的stack overflow。
rm -f gcc/cc1.exe gcc/cc1plus.exe
make install DESTDIR=$DIR LDFLAGS="-s -Wl,--stack=0x2000000"
libtool: link: (cd ".libs" && rm -f "libgomp.lib" && ln -s "libgomp-1.dll" "libgomp.lib")
Creating library file: .libs/libgomp-1.dll
libtool: link: (cd ".libs" && rm -f "libgomp.lib" && ln -s "libgomp-1.dll" "libgomp.lib")
libtool: link: /usr/lib/gcc/mingw32/4.4.3/../../../../mingw32/bin/ar rc .libs/libgomp.lib alloc.o barrier.o critical.o env.o error.o iter.o iter_ull.o loop.o loop_ull.o ordered.o parallel.o sections.o single.o task.o team.o work.o lock.o mutex.o proc.o sem.o bar.o ptrlock.o time.o fortran.o affinity.o
/usr/lib/gcc/mingw32/4.4.3/../../../../mingw32/bin/ar: .libs/libgomp.lib: File format not recognized
make[4]: *** [libgomp.la] 错误 1
make[4]: Leaving directory `/home/loaden/AUR/mingw32/build/gcc-4.4.3/mingw32/libgomp'
make[3]: *** [all-recursive] 错误 1
make[3]: Leaving directory `/home/loaden/AUR/mingw32/build/gcc-4.4.3/mingw32/libgomp'
make[2]: *** [all] 错误 2
make[2]: Leaving directory `/home/loaden/AUR/mingw32/build/gcc-4.4.3/mingw32/libgomp'
make[1]: *** [all-target-libgomp] 错误 2
make[1]: Leaving directory `/home/loaden/AUR/mingw32/build/gcc-4.4.3'
make: *** [all] 错误 2
GNU dlltool用于需要使用动态链接库(DLLs)时。下面的选项是值得我们关注的:
-l --output-lib <outname> 生成导入库
-D --dllname <name> 指定用于生成导入库的DLL文件名
-d --input-def <deffile> 读取DEF文件
-U --add-underscore 为导入库里的元素加上下划线前缀
-k --kill-at 去除导出的名称里的@<n>
dlltool -D sample.dll -d sample.def -l sample.a
mingw32-dlltool -D libgomp-1.dll -l libgomp.lib
# 配置
../../src/gcc-4.4.3/configure \
--prefix=/mingw \
--host=mingw32 \
--target=mingw32 \
--build=i686-pc-linux-gnu \
--enable-languages=c,c++ \
--enable-shared \
--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.php
make CFLAGS="-O2 -D__USE_MINGW_ACCESS" \
BOOT_CFLAGS="-O2 -D__USE_MINGW_ACCESS" \
CFLAGS_FOR_TARGET="-I$DIR/pthreads/include -O2 -D__USE_MINGW_ACCESS" \
CXXFLAGS="-mthreads -O2 -D__USE_MINGW_ACCESS" \
BOOT_CXXFLAGS="-mthreads -O2 -D__USE_MINGW_ACCESS" \
CXXFLAGS_FOR_TARGET="-mthreads -O2 -D__USE_MINGW_ACCESS" \
LDFLAGS="-s" BOOT_LDFLAGS="-s" \
LDFLAGS_FOR_TARGET="-L$DIR/pthreads/lib -s"
# libgomp错误处理:修改mingw32/libgomp/libtool脚本,将".lib"改成".dll.a",共两处:
# 1. library_names_spec="\${libname}\`echo \${release} | \$SED -e s/[.]/-/g\`\${versuffix}\${shared_ext} \$libname.lib"
# 2. reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite:
# 之后重复上一步,即可编译成功!