如何解决将 yaml-cpp 与 conan 联系起来
我在我的柯南文件 yaml-cpp
中使用来自 conan center 的 yaml-cpp/0.6.3
以及其他依赖项。
其余的库链接正确,因此我的 CMakeLists.txt
文件中肯定缺少某些内容。 (也许是一些额外的定义......?)
直到现在,这些行:
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
set(CMAKE_CXX_STANDARD 20)
它工作得很好(对于其他库,如bullet、glm...)
在链接时,会出现缺少实现的问题:
cmake --build build --config Debug --target all -- -j 10
/usr/bin/ld: CMakeFiles/my-project.dir/src/MySourceFile.cpp.o: in function `YAML::Node::Scalar[abi:cxx11]() const':
/home/my-user/.conan/data/yaml-cpp/0.6.3/_/_/package/82ef5eac51c38971dea2fd342dd55ddf2ddfbbc3/include/yaml-cpp/node/impl.h:169: undefined reference to `YAML::detail::node_data::empty_scalar[abi:cxx11]()'
/usr/bin/ld: CMakeFiles/my-project.dir/src/MySource.cpp.o: in function `tojson::loadyaml(std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char> > const&)':
/home/my-user/my-project/lib/nlohmann/tojson.hpp:162: undefined reference to `YAML::LoadFile(std::__cxx11::basic_string<char,std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
似乎问题在于 YAML::LoadFile
似乎未定义。
(我也尝试在没有 tojson
的情况下使用它)
YAML::Node test = YAML::LoadFile("test.yaml");
解决方法
包没问题,但您的配置文件配置错误。
对`YAML::LoadFile(std::__cxx11::basic_string
您必须更新您的 libcxx 设置:
conan profile update settings.compiler.libcxx=libstdc++11 default
更多信息:https://docs.conan.io/en/latest/howtos/manage_gcc_abi.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。