我想在x86_64-unknown-linux-gnu中使用winphreads在i686-w64-mingw32中构建一个交叉编译器mingw-w64 gcc。从源代码包mingw-w64-v3.1.0 / mingw-w64-doc中的文档中,我知道如何使用win32线程构建交叉gcc。但是,我需要使用c ++ 11线程,所以我需要使用posix线程构建交叉gcc。而且我知道mingw-w64支持mingw-w64-v3.1.0 / mingw-w64-libraries / winpthreads中的posix线程。不幸的是,上面的文档没有解释如何构建交叉编译器mingw-w64 gcc。
附加要求,我需要gcc,g ++ gfortran和dwarf2异常模式
结果,我尝试以下程序:
1 #!/bin/sh
2
3 threads=8
4
#build binutils
5 wget http://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.bz2 -O - | tar -xj
6 cd binutils-2.24
7 mkdir build; cd $_
8 ../configure --prefix=$HOME/cross --with-sysroot=$HOME/cross --target=i686-w64-mingw32 --disable-multilib
9 make -j $threads; make check; make install-strip; cd ..; cd ..; rm -rf ~-
10
#install mingw-w64-headers
11 wget http://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v3.1.0.tar.bz2/download -O - | tar -xj
12 cd mingw-w64-v3.1.0/mingw-w64-headers
13 mkdir build; cd $_
14 ../configure --prefix=$HOME/cross/i686-w64-mingw32
15 make install; cd $HOME
16
17 ln -s $HOME/cross/i686-w64-mingw32 $HOME/cross/mingw
18
#build static gcc
19 wget http://www.netgull.com/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.bz2 -O - | tar -xj
20 cd gcc-4.8.2
21 mkdir build; cd $_
22 ../configure --prefix=$HOME/cross --with-sysroot=$HOME/cross --target=i686-w64-mingw32 --with-gmp=$HOME/gcc --with-mpfr=$HOME/gcc --with-mpc=$HOME/gcc --with-isl=$HOME/gcc --with-cloog=$HOME/gcc --enable-threads=posix --enable-checking=release --disable-multilib --enable-languages=c,c++,fortran --enable-__cxa_atexit --enable-dwarf2
23 make -j $threads all-gcc; make install-gcc
24
25 export PATH=$HOME/cross/bin:$PATH
26
#build mingw-w64-crt
27 cd $HOME/mingw-w64-v3.1.0/mingw-w64-crt
28 mkdir build; cd $_
29 ../configure --prefix=$HOME/cross/i686-w64-mingw32 --with-sysroot=$HOME/cross --host=i686-w64-mingw32
30 make -j $threads; make install-strip
31
#build winpthreads
32 cd $HOME/mingw-w64-v3.1.0/mingw-w64-libraries/winpthreads
33 mkdir build; cd $_
34 ../configure --prefix=$HOME/cross/i686-w64-mingw32 --with-sysroot=$HOME/cross --host=i686-w64-mingw32 --enable-shared=no
35 make -j $threads; make install-strip
36
#build full gcc
37 cd $HOME/gcc-4.8.2/build
38 make -j $threads; make check; make install-strip
然而,当我在最后一步构建完整的gcc时,我得到如下错误:
.libs/compatibility-atomic-c++0x.o: In function `_gthread_mutex_lock':
/home/cguo/gcc-4.8.2/build/i686-w64-mingw32/libstdc++-v3/include/i686-w64-mingw32/bits/gthr-default.h:748: undefined reference to `_imp__pthread_mutex_lock'
.libs/compatibility-atomic-c++0x.o: In function `_gthread_mutex_unlock':
/home/cguo/gcc-4.8.2/build/i686-w64-mingw32/libstdc++-v3/include/i686-w64-mingw32/bits/gthr-default.h:778: undefined reference to `_imp__pthread_mutex_unlock'
.libs/compatibility-atomic-c++0x.o: In function `_gthread_mutex_lock':
/home/cguo/gcc-4.8.2/build/i686-w64-mingw32/libstdc++-v3/include/i686-w64-mingw32/bits/gthr-default.h:748: undefined reference to `_imp__pthread_mutex_lock'
.libs/compatibility-atomic-c++0x.o: In function `_gthread_mutex_unlock':
/home/cguo/gcc-4.8.2/build/i686-w64-mingw32/libstdc++-v3/include/i686-w64-mingw32/bits/gthr-default.h:778: undefined reference to `_imp__pthread_mutex_unlock'
collect2: error: ld returned 1 exit status
make[5]: *** [libstdc++.la] Error 1
make[5]: Leaving directory `/home/cguo/gcc-4.8.2/build/i686-w64-mingw32/libstdc++-v3/src'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/home/cguo/gcc-4.8.2/build/i686-w64-mingw32/libstdc++-v3/src'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/cguo/gcc-4.8.2/build/i686-w64-mingw32/libstdc++-v3'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/cguo/gcc-4.8.2/build/i686-w64-mingw32/libstdc++-v3'
make[1]: *** [all-target-libstdc++-v3] Error 2
make[1]: *** Waiting for unfinished jobs....
config.status: executing libtool commands
config.status: executing gstdint.h commands
make[1]: Leaving directory `/home/cguo/gcc-4.8.2/build'
make: *** [all] Error 2
那么,如何解决这个问题?
非常感谢