【问题标题】:Problems cross-compiling boost 1.57 from Linux to Windows从 Linux 到 Windows 的交叉编译 boost 1.57 的问题
【发布时间】:2015-04-09 21:04:46
【问题描述】:

我正在尝试将 boost 1.57 从 64 位 Debian 测试交叉编译到 32 位 Windows。

Boost 有cross-compile page,这并没有太大帮助。例如,我不得不四处搜索并发现我需要使用-sNO_BZIP2=1 和zlib 明确禁用bzip2 - 它会自动禁用它(以前你必须指定-sNO_ZLIB=1,但它现在已经坏了) .

所以,经过一些尝试和错误,我得出了:

$ 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 用于 10 个并发作业,因为我有 8 个逻辑 cpu 核心。

address-model=32 用于 32 位构建

binary-format=pesuggested 作为在 libs/context/src/asm/make_i386_sysv_elf_gas.S 中构建失败的解决方法。

以上失败:

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...

此时我被卡住了,我不知道如何解决这个问题,谷歌似乎也没有帮助。

【问题讨论】:

  • 通过禁用我不需要的失败库来让它工作./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
  • 您应该将此作为答案发布。这可能对其他人有用。接受你自己的答案是完全可以的。谢谢

标签: c++ linux boost compilation cross-compiling


【解决方案1】:

通过简单地禁用失败的库来让它工作,我碰巧不需要它

./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

实际上,一些被禁用的库可能不会失败,我只是查看了所有库的列表并禁用了那些与我需要的完全无关的库。

当然,这并不能解决将 所有 的 boost 库交叉编译到 Windows 的问题,很高兴知道如何正确地做到这一点,但现在我满足于那个。

【讨论】:

  • 问题的根源在于 Boost.Context 目前不支持使用 MinGW 的 Windows 交叉编译。 See this ticket on their bug tracker。每个平台只支持一个汇编程序,对于 Windows,即 MASM,它不能在 Linux 上运行。跟踪器上提供了一个补丁来制作可以使用gas 组装的文件,但它适用于较旧的 Boost 版本。
猜你喜欢
  • 1970-01-01
  • 2023-01-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-29
  • 2017-02-03
  • 2014-01-16
  • 1970-01-01
相关资源
最近更新 更多