【问题标题】:Why can't I link to spdlog library installed with conan为什么我不能链接到用柯南安装的 spdlog 库
【发布时间】:2020-04-03 20:12:37
【问题描述】:

我有一个简单的CMake项目,尝试使用柯南安装的spdlog库(1.5.0版)。

但是在构建时出现以下错误:

undefined reference to `spdlog::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

我不确定问题是来自我的设置、conan 还是 spdlog 库。 谁能帮我看看哪里?

我的本​​地设置: Ubuntu 19.04, QT 创造者, Clang 9(在 IDE 和柯南中), 柯南 1.24.0

【问题讨论】:

    标签: c++ conan spdlog


    【解决方案1】:

    请先从柯南文档https://docs.conan.io/en/latest/getting_started.html 中的“入门”开始,确保它有效,然后从那里开始做你自己的例子。

    在入门中,您将有一个使用 ConanCenter 中现有库的示例。还有一个突出的“重要”通知说:

    If you are using GCC compiler >= 5.1, Conan will set the compiler.libcxx to the old ABI for backwards compatibility. You can change this with the following commands:
    
    $ conan profile new default --detect  # Generates default profile detecting GCC and sets old ABI
    $ conan profile update settings.compiler.libcxx=libstdc++11 default  # Sets libcxx to C++11 ABI
    

    基本上默认的自动检测配置文件使用 libstdc++,而您的编译器很可能使用 libstdc++11。您需要更改默认配置文件:

    $ conan profile update settings.compiler.libcxx=libstdc++11 default
    

    然后再次执行“conan install”,然后构建。

    【讨论】:

    • 谢谢你的详细描述:)确实是编译器设置。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-15
    相关资源
    最近更新 更多