繁体   English   中英

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

[英]How to build Boost with static ICU via MinGW on Linux for Windows

我想在 Docker Linux 映像中使用 MinGW for Windows 构建 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

我需要更改什么才能在b2运行中使icu切换为yes

编辑2020-02-03:部分答案是 Boost 1.73.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 to ucol_open_65 / ucol_close_65 这些函数在我的 ICU 静态库中被命名为ucol_open / ucol_close

暂无
暂无

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

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