简体   繁体   English

从Linux到Windows交叉编译boost 1.57的问题

[英]Problems cross-compiling boost 1.57 from Linux to Windows

I'm trying to cross-compile boost 1.57 from 64-bit Debian Testing to 32-bit Windows. 我正在尝试将Boost 1.57从64位Debian测试交叉编译到32位Windows。

Boost has cross-compile page , which doesn't really help much. Boost具有交叉编译页面 ,实际上并没有太大帮助。 For example, I had to google around and figure out that I need to explicitly disable bzip2 with -sNO_BZIP2=1 and zlib with nothing -- it will auto-disable it (previously you had to specify -sNO_ZLIB=1 , but it has broke now). 例如,我必须四处-sNO_BZIP2=1 ,发现我需要使用-sNO_BZIP2=1显式禁用bzip2以及不使用zlib的任何方法-它会自动禁用它(以前,您必须指定-sNO_ZLIB=1 ,但是它已经崩溃了现在)。

So, after some trials and errors, I have come to: 因此,经过一番尝试和错误,我得出以下结论:

$ i686-w64-mingw32-g++ -v
Using built-in specs.
COLLECT_GCC=i686-w64-mingw32-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-w64-mingw32/4.9-win32/lto-wrapper
Target: i686-w64-mingw32
Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --libexecdir='/usr/lib/gcc-mingw-w64' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++ --enable-lto --with-plugin-ld --enable-threads=win32 --program-suffix=-win32 --program-prefix=i686-w64-mingw32- --target=i686-w64-mingw32 --with-as=/usr/bin/i686-w64-mingw32-as --with-ld=/usr/bin/i686-w64-mingw32-ld
Thread model: win32
gcc version 4.9.1 (GCC)
$ wget http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.7z
$ ls
boost_1_57_0.7z
$ 7z x boost_1_57_0.7z 
$ cd boost_1_57_0
$ echo "using gcc : : i686-w64-mingw32-g++ ;" > user-config.jam
$ ./bootstrap.sh
$ ./b2 -j10 --user-config=user-config.jam toolset=gcc-mingw address-model=32 binary-format=pe target-os=windows release --prefix=/usr/i686-w64-mingw32/local --without-python --without-wave -sNO_BZIP2=1

-j10 for 10 concurrent jobs, since I got 8 logical cpu cores. -j10用于10个并发作业,因为我有8个逻辑cpu核心。

address-model=32 for 32-bit build address-model=32用于32位构建)

binary-format=pe was suggested as workaround of the build failing in libs/context/src/asm/make_i386_sysv_elf_gas.S . libs/context/src/asm/make_i386_sysv_elf_gas.S建议使用 binary-format=pe作为构建失败的解决方法。

The above fails with: 上面的失败与:

gcc.compile.c++ bin.v2/libs/context/build/gcc-mingw-4.9.1/release/address-model-32/binary-format-pe/link-static/target-os-windows/threading-multi/unsupported.o
libs/context/src/unsupported.cpp:7:2: error: #error "platform not supported"
 #error "platform not supported"
  ^

    "i686-w64-mingw32-g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -mthreads -m32  -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_SOURCE -DNDEBUG  -I"." -c -o "bin.v2/libs/context/build/gcc-mingw-4.9.1/release/address-model-32/binary-format-pe/link-static/target-os-windows/threading-multi/unsupported.o" "libs/context/src/unsupported.cpp"

...failed gcc.compile.c++ bin.v2/libs/context/build/gcc-mingw-4.9.1/release/address-model-32/binary-format-pe/link-static/target-os-windows/threading-multi/unsupported.o...
...skipped <pbin.v2/libs/context/build/gcc-mingw-4.9.1/release/address-model-32/binary-format-pe/link-static/target-os-windows/threading-multi>libboost_context.a(clean) for lack of <pbin.v2/libs/context/build/gcc-mingw-4.9.1/release/address-model-32/binary-format-pe/link-static/target-os-windows/threading-multi>unsupported.o...
...skipped <pbin.v2/libs/context/build/gcc-mingw-4.9.1/release/address-model-32/binary-format-pe/link-static/target-os-windows/threading-multi>libboost_context.a for lack of <pbin.v2/libs/context/build/gcc-mingw-4.9.1/release/address-model-32/binary-format-pe/link-static/target-os-windows/threading-multi>unsupported.o...
...skipped <pstage/lib>libboost_context.a for lack of <pbin.v2/libs/context/build/gcc-mingw-4.9.1/release/address-model-32/binary-format-pe/link-static/target-os-windows/threading-multi>libboost_context.a...
...failed updating 1 target...
...skipped 3 targets...

At this point I have become stuck, I don't know how to fix this and google doesn't seem to help. 在这一点上,我已经陷入困境,我不知道如何解决这个问题,谷歌似乎没有帮助。

Got it to work by simply disabling failing libraries, which I happened to not need anyway 只需禁用失败的库即可使其正常工作,我碰巧也不需要

./b2 -j10 --user-config=user-config.jam toolset=gcc-mingw address-model=32 binary-format=pe target-os=windows release --prefix=/usr/i686-w64-mingw32/local --without-python --without-wave --without-context --without-coroutine --without-mpi --without-test --without-graph --without-graph_parallel -sNO_BZIP2=1

Actually, some of the disabled libraries might not be failing, I just went over the list of all libraries and disabled the ones which were totally unrelated to what I needed. 实际上,某些禁用的库可能不会失败,我只是浏览了所有库的列表,并禁用了与我需要的库完全无关的库。

Of course that doesn't solve the issue of cross-compiling all of boost libraries to Windows, it would be nice to know how to do that correctly, but for now I'm content with that. 当然,这并不能解决将所有 Boost库交叉编译到Windows的问题,很高兴知道如何正确执行此操作,但是现在我对此很满意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM