【问题标题】:Compile boost-python 1.73.0 for Windows with MinGW64 on Fedora在 Fedora 上使用 MinGW64 为 Windows 编译 boost-python 1.73.0
【发布时间】:2021-01-15 00:13:55
【问题描述】:

我需要在 Fedora 的 rawhide 上使用 MinGW64 编译 boost-python 1.73.0,这样我就可以为 Windows 10 64 位构建 Python 绑定(不,很遗憾我不能使用 Visual Studio)。不幸的是,Fedora 的 mingw64-boost 软件包中唯一缺少的库是 boost-python,啊!

其实所有的依赖都打包在Fedora for MinGW64上,挺好的。因此,我正在尝试通过以下方式建立自己:

wget https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.bz2
tar -xjf boost_1_73_0.tar.bz2 && cd boost_1_73_0
./bootstrap.sh
# in a docker container, so /root
./b2 --with-python address-model=64 target-os=windows toolset=gcc-mingw64 \
     variant=release link=shared --user-config=/root/user-config.jam 

还有一个~/user-config.jam

using gcc : mingw64 : x86_64-w64-mingw32-g++ ;

using python
     : 3.9
     : /usr/x86_64-w64-mingw32/sys-root/mingw/bin/python3.9.exe
     : /usr/x86_64-w64-mingw32/sys-root/mingw/include/python3.9
     : /usr/x86_64-w64-mingw32/sys-root/mingw/lib/python3.9 ;

它成功运行了一段时间,但随后出现错误

/usr/lib/gcc/x86_64-w64-mingw32/10.2.1/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lutil
collect2: error: ld returned 1 exit status

所以libutil 不知何故不见了。多么具体的名字啊!我尝试(重新)安装所有 glibc 软件包(libutil.so 显然通常在其中),但无济于事。还找到了/usr/x86_64-w64-mingw32/sys-root/mingw/lib/libutildll.a,尝试通过./b2 library=... 包含它,再次失败。

这里发生了什么?顺便说一句,this gist 的完整命令失败了。

【问题讨论】:

    标签: boost mingw cross-compiling boost-python mingw-w64


    【解决方案1】:

    因此,这需要对 boost 源进行修补,以摆脱 libutil 链接。要完全编译,必须应用一批其他补丁文件。这是我在 fedora:rawhide 中的完整命令链:

    1. 获取来源
    wget https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.bz2
    tar -xjf boost_1_73_0.tar.bz2
    cd boost_1_73_0
    
    1. 设置~/user-config.jam
    cat >> ~/user-config.jam <<EOL
    using gcc : mingw64 : x86_64-w64-mingw32-g++ ;
    
    using python
         : 3.9
         : /usr/x86_64-w64-mingw32/sys-root/mingw/bin/python3.9
         : /usr/x86_64-w64-mingw32/sys-root/mingw/include/python3.9
         : /usr/x86_64-w64-mingw32/sys-root/mingw/lib/python3.9/config-3.9 ;
    EOL
    
    1. 自举提升
    ./bootstrap.sh --with-icu=/usr/x86_64-w64-mingw32/sys-root/mingw/ --with-toolset=gcc
    
    1. ./boost_1_73_0_patches中的所有文件打补丁

    大多这样应用:

    patch -p1 -i patches/boost-1.63.0-python-test-PyImport_AppendInittab.patch
    
    1. 构建 boost-python
    ./b2 address-model=64 link=shared runtime-link=shared threading=multi threadapi=win32 toolset=gcc variant=release python=3.9 --with-python
    

    【讨论】:

      猜你喜欢
      • 2017-11-07
      • 2020-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多