简体   繁体   中英

Why can't I link to spdlog library installed with conan

I have a simple CMake project and try to use the spdlog library (version 1.5.0) installed by conan.

But when building I get the following error:

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

I'm not sure if the problem comes from my setup, conan or the spdlog library. Can anyone help me where to look?

My local setup: Ubuntu 19.04, QT Creator, Clang 9 (in the IDE and conan), conan 1.24.0

Please start first with the "Getting Started" from the Conan docs https://docs.conan.io/en/latest/getting_started.html , make sure it works, and then, start from there to do your own examples.

In the getting started you will have an example of consuming existing libraries in ConanCenter. There is also a prominent "Important" notice that says:

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

Basically the default auto-detected profile is using libstdc++, while your compiler is mostly likely using libstdc++11. You need to change the default profile with:

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

And then do "conan install" again, and build.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM