如何在Windows的Linux上通过MinGW使用静态ICU构建Boost

问题描述 投票:0回答:1

我想用MinGW for Windows在Docker Linux映像中构建C ++ Boost库。对于libzbz2xzzstdICU,这已经起作用,并且安装了相应的文件。一切都是静态链接。

文件系统结构如下:

$ ls -l /mingw/
drwxr-xr-x 1 root root 4096 Feb  2 00:09 include
drwxr-xr-x 1 root root 4096 Feb  2 00:09 lib
drwxr-xr-x 5 root root 4096 Feb  2 00:09 share
$ ls -l /mingw/lib/
drwxr-xr-x 3 root root     4096 Feb  2 00:09 icu
-rw-r--r-- 1 root root   371114 Feb  1 19:58 libbz2.a
-rw-r--r-- 1 root root  1940512 Feb  2 00:03 liblzma.a
-rwxr-xr-x 1 root root      876 Feb  2 00:03 liblzma.la
-rwxr-xr-x 1 root root      736 Feb  2 00:09 libsicudt.a
-rwxr-xr-x 1 root root 10895028 Feb  2 00:09 libsicuin.a
-rwxr-xr-x 1 root root   143990 Feb  2 00:09 libsicuio.a
-rwxr-xr-x 1 root root  5196448 Feb  2 00:09 libsicuuc.a
-rw-r--r-- 1 root root   118758 Feb  1 18:15 libz.a
-rw-r--r-- 1 root root   850738 Feb  1 21:11 libzstd.a
drwxr-xr-x 1 root root     4096 Feb  2 00:09 pkgconfig
$ ls -l /mingw/include/
-rw-r--r-- 1 root root   6240 Feb  1 19:58 bzlib.h
-rw-r--r-- 1 root root   4569 Nov  4 17:54 cover.h
drwxr-xr-x 2 root root   4096 Feb  2 00:03 lzma
-rw-r--r-- 1 root root   9817 Feb  2 00:03 lzma.h
drwxr-xr-x 2 root root   4096 Feb  2 00:09 unicode
-rw-r--r-- 1 root root  11500 Nov  4 17:54 zbuff.h
-rw-rw-r-- 1 root root  16298 Jan 15  2017 zconf.h
-rw-r--r-- 1 root root  17203 Nov  4 17:54 zdict.h
-rw-rw-r-- 1 root root  96239 Jan 15  2017 zlib.h
-rw-r--r-- 1 root root 119972 Nov  4 17:54 zstd.h
-rw-r--r-- 1 root root   3751 Nov  4 17:54 zstd_errors.h

我还创建了一个site-config.jam文件,由于b2找到了libzbz2xzzstd

$ more /etc/site-config.jam 
using gcc : : x86_64-w64-mingw32-g++ : 
    <cxxflags>-DBOOST_ASIO_HAS_STD_STRING_VIEW
    <cxxflags>-DBOOST_ASIO_HAS_STD_IOSTREAM_MOVE
    <cxxflags>--sysroot=/mingw
    <cxxflags>-std=c++17 ;
using zlib : : <include>/mingw/include <search>/mingw/lib ;
using bzip2 : : <include>/mingw/include <search>/mingw/lib ;
using lzma : : <include>/mingw/include <search>/mingw/lib ;
using zstd : : <include>/mingw/include <search>/mingw/lib ;

不幸的是,这对于ICU是不可能的。使用-sICU_PATH也不起作用。

我当前要构建的命令行为:

$ cd /mnt/boost_1_72_0
$ ./b2 toolset=gcc variant=release threading=multi link=static \
  target-os=windows architecture=x86 address-model=64 abi=ms binary-format=pe \
  -sICU_PATH=/mingw/lib \
  --layout=system --prefix=/install \
  --without-python --without-graph_parallel --without-mpi \
  -j $(nproc) install

此打印:

Performing configuration checks

    - default address-model    : 64-bit
    - default architecture     : x86
    - C++11 mutex              : yes
[...]
    - has_icu builds           : no
    - zlib                     : yes
    - bzip2                    : yes
    - lzma                     : yes
    - zstd                     : yes
    - lzma                     : yes
    - has_lzma_cputhreads builds : yes
    - iconv (libc)             : no
    - iconv (separate)         : no
    - icu                      : no
    - icu (lib64)              : no
    - native-atomic-int32-supported : yes
    - message-compiler         : no
    - native-syslog-supported  : no
    - pthread-supports-robust-mutexes : no
    - compiler-supports-ssse3  : yes
    - compiler-supports-avx2   : yes
    - gcc visibility           : yes
    - long double support      : yes
    - libbacktrace builds      : no
    - addr2line builds         : no
    - WinDbg builds            : no
    - WinDbgCached builds      : no
    - BOOST_COMP_GNUC >= 4.3.0 : yes
[...]

您可以通过我的测试Docker映像运行并重现此内容:

$ docker run -it --rm bebuch/boost-with-static-icu-prepared:latest

要在icu运行中将yes切换到b2,我需要更改什么?

Edit 2020-02-03:答案的一部分是在Boost 1.73.0中修复的错误:

c++ boost mingw cross-compiling icu
1个回答
0
投票

主要问题是Boost.Regex 1.72.0的构建配置中的两个错误。

修复/解决它们之后,构建成功通过:

./b2 toolset=gcc variant=release threading=multi link=static \
  target-os=windows architecture=x86 address-model=64 abi=ms binary-format=pe \
  include=/mingw/include library-path=/mingw/lib \
  define=U_DISABLE_VERSION_SUFFIX=1 \
  --layout=system --prefix=/install \
  --without-python --without-graph_parallel --without-mpi \
  -j $(nproc) install

includelibrary-path是查找头文件和库所必需的。这也会使site-config.jam文件的最后4行过时。

U_DISABLE_VERSION_SUFFIX=1是必需的,因为我的ICU版本不使用此功能。没有它,您可能会收到链接器错误,例如undefined reference toucol_open_65/ ucol_close_65。这些函数在我的ICU静态库中仅命名为ucol_open / ucol_close

© www.soinside.com 2019 - 2024. All rights reserved.