【问题标题】:lib-boost ld: symbol(s) not found for architecture arm64lib-boost ld:找不到架构 arm64 的符号
【发布时间】:2021-07-28 12:36:02
【问题描述】:

我用 lib-boost 编写了一个简单的代码来加载一个 CSV 文件。编译后出现以下错误:

Undefined symbols for architecture arm64:
  "boost::iostreams::mapped_file_source::init()", referenced from:
      boost::iostreams::mapped_file_source::mapped_file_source<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, long) in class_map.cpp.o
  "boost::iostreams::mapped_file_source::open_impl(boost::iostreams::basic_mapped_file_params<boost::iostreams::detail::path> const&)", referenced from:
      void boost::iostreams::mapped_file_source::open<boost::iostreams::detail::path>(boost::iostreams::basic_mapped_file_params<boost::iostreams::detail::path> const&) in class_map.cpp.o
  "boost::iostreams::mapped_file_source::end() const", referenced from:
      MyMap::loadCSV(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in class_map.cpp.o
  "boost::iostreams::mapped_file_source::begin() const", referenced from:
      MyMap::loadCSV(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in class_map.cpp.o
ld: symbol(s) not found for architecture arm64

我使用自制软件安装了 boost,它包含在 cmakelist 中。

Found Boost: /opt/homebrew/lib/cmake/Boost-1.75.0/BoostConfig.cmake (found version "1.75.0") found components: system filesystem 

【问题讨论】:

    标签: c++ boost cmake apple-m1


    【解决方案1】:

    我发现这是一个 cmake 配置问题。我必须添加iostreams

    find_package(Boost REQUIRED COMPONENTS system iostreams)
    
    target_link_libraries(program pthread z expat bz2 ${Boost_LIBRARIES})
    

    【讨论】:

      猜你喜欢
      • 2019-10-03
      • 1970-01-01
      • 2023-02-15
      • 1970-01-01
      • 2018-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多