【问题标题】:Cross compiling libtorrent for raspberry pi 3 model B为树莓派 3 模型 B 交叉编译 libtorrent
【发布时间】:2020-08-22 02:27:41
【问题描述】:

我一直在尝试为使用boost build 进行编译的树莓派交叉编译jlibtorrent。我正在使用the officially provided cross compiler 和以下config.jam

import os ;

using gcc : arm : arm-linux-gnueabihf-g++ :
    <cxxflags>-fPIC
    <cxxflags>-std=c++14
    <cxxflags>-fno-strict-aliasing
    <cxxflags>-fvisibility=hidden
    <linkflags>-m32
    <linkflags>-static-libstdc++
    <linkflags>-static-libgcc
    <linkflags>"-z noexecstack"
    # debug information
    <cxxflags>-g
    <cxxflags>-gdwarf-4
    <cxxflags>-ggdb
    ;

我基本上复制了 linux-x86 的现有配置并更换了编译器,但我收到以下编译错误:

libtorrent/src/entry.cpp: In member function 'libtorrent::entry& libtorrent::entry::operator[](libtorrent::string_view)':
libtorrent/src/entry.cpp:86:33: error: no matching function for call to 
'std::map<std::basic_string<char>, libtorrent::entry, libtorrent::aux::strview_less, std::allocator<std::pair<const std::basic_string<char>, libtorrent::entry> > >::find(libtorrent::string_view&)' 

auto const i = dict().find(key);

我唯一的猜测是交叉编译器的版本(4.9.3)与libtorrent不兼容,因为我在linux-32-config.jam中看到它使用了g++-5。还有什么我想念的吗? 您可以找到修改后的存储库in my github repositories。我正在使用swig/build-linux-armv7.sh 进行构建。

【问题讨论】:

  • 作为一个有点不相关的注释。 Jamfile 工具集并不意味着包含 c++ 版本、-fPIC、-g 和 -static-*。你可以在 b2 命令行上控制它:debug-symbols=on runtime-link=static cxxstd=14。此外,libtorrent 支持 C++ 别名规则,因此技术上没有必要禁用它们

标签: c++ boost libtorrent boost-build libtorrent-rasterbar


【解决方案1】:

感谢@Arvid,我设法使用 libtorrent (RC_1_2) 的当前稳定分支和以下 jam 文件编译它,您可以找到 here

import os ;

using gcc : arm : arm-linux-gnueabihf-g++ :
    <cxxflags>-fPIC
    <cxxflags>-std=c++11
    <cxxflags>-fno-strict-aliasing
    <cxxflags>-fvisibility=hidden
    <linkflags>-static-libstdc++
    <linkflags>-static-libgcc
    <linkflags>"-z noexecstack"
    # debug information
    <cxxflags>-g
    <cxxflags>-gdwarf-4
    <cxxflags>-ggdb;

【讨论】:

    【解决方案2】:

    该调用 (std::map::find()) 是在 C++14 中添加的(参见 docs)。我看到你也在命令行上传递了-std=c++14。你确定你的 GCC 支持 C++14 吗?好像有点老了。

    libtorrent 当前的 stable 分支只需要 C++11 支持,如果这是你正在构建的分支,编译器支持检测here 可能有问题。如果您从 libtorrent master 构建,则需要适当的 C++14 支持。因此,在这种情况下,您可能需要使用稳定版本。

    【讨论】:

    • 我更改了-std=c++14 并删除了&lt;linkflags&gt;-m32 并从当前的稳定分支构建(我猜是RC_1_2?),它现在确实可以编译。非常感谢:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-19
    • 1970-01-01
    • 2021-05-17
    • 1970-01-01
    • 1970-01-01
    • 2013-12-12
    相关资源
    最近更新 更多