使用柯南包管理器提升链接错误

Boost link error using Conan package manager

本文关键字:链接 错误 管理器 柯南      更新时间:2023-10-16

我在使用柯南版本的Boost时遇到了以下错误。代码使用操作系统的库(尽管在另一个系统上(编译得很好。

错误输出:

[  2%] Built target logging
[ ...] ....
[ 18%] Linking CXX executable ../bin/DEPTHFILE_UTILS
../lib/lib_logging.so: undefined reference to "boost::log::v2_mt_posix::aux::code_convert_impl(wchar_t const*, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned long, std::locale const&)"
../lib/lib_logging.so: undefined reference to "boost::log::v2_mt_posix::parse_error::throw_(char const*, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::log::v2_mt_posix::attribute_name const&)"
../lib/lib_logging.so: undefined reference to "boost::log::v2_mt_posix::sinks::text_file_backend::consume(boost::log::v2_mt_posix::record_view const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)"
collect2: error: ld returned 1 exit status
src/CMakeFiles/DEPTHFILE_UTILS.dir/build.make:146: set di istruzioni per l'obiettivo "bin/DEPTHFILE_UTILS" non riuscito
make[2]: *** [bin/DEPTHFILE_UTILS] Errore 1
CMakeFiles/Makefile2:1018: set di istruzioni per l'obiettivo "src/CMakeFiles/DEPTHFILE_UTILS.dir/all" non riuscito
make[1]: *** [src/CMakeFiles/DEPTHFILE_UTILS.dir/all] Errore 2
Makefile:94: set di istruzioni per l'obiettivo "all" non riuscito

我已经在 logging.h 标头中定义了BOOST_LOG_DYN_LINK,我在其中声明了所有与日志相关的宏。 lib_logging.soinit()方法所在的位置。CMake 找到所有需要的库并且工作正常。

柯南配置:

[requires]
boost/1.66.0@conan/stable
gtest/1.8.1@bincrafters/stable
opencv/3.4.5@conan/stable
[generators]
cmake
[options]
boost:shared=True

任何帮助,不胜感激。

系统信息:

  • 在装有 Ubuntu 16.04 LTS 的虚拟机上运行
  • 柯南版本 1.13.0
  • CXX 编译器 GNU
  • CXX 编译器版本 5.4.0

柯南配置:

arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=5
os=Linux
os_build=Linux

命令在目录中运行build(源代码外构建(,使用以下命令作为参考:

virtualenv vconan -no-site-package
source vconan/bin/activate
pip install -upgrade pip
pip install conan
conan install ../
deactivate
cmake -DCMAKE_BUILD_TYPE=Release -DCONAN_BUILD=ON ..
make

多亏了@uilianries提出的问题,我意识到了我的错误:

compiler.libcxx=libstdc++

这是错误的。在安装命令中,我添加了以下内容:

conan install --settings compiler.libcxx="libstdc++11" ../

您还可以在调整compiler.libcxx=libstdc++11 ~/.conan/profiles/default编辑默认配置文件。

现在一切正常。