使用柯南包管理器提升链接错误
Boost link error using Conan package manager
我在使用柯南版本的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.so
是init()
方法所在的位置。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
编辑默认配置文件。
现在一切正常。
相关文章:
- 静态数据成员的问题-修复链接错误会导致编译器错误
- Visual Studio mkl_link_tool.exe链接错误
- C++ 实现模板单例类时出现链接错误
- 使用类模板的方法链接错误
- MySQL C++连接器链接错误
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 运行 C++ 单元测试时LNK2005链接错误
- 对 CMake 中'cudaRegisterLinkedBinary'链接错误的未定义引用?
- 链接错误,包括我创建的相同头文件 - C++
- 在Embarcadero C++ Builder中生成的DLL未解决的外部链接错误
- 使用标头保护的多个定义链接错误
- 链接错误:未定义对 stdscr 和 wgetch 的引用
- 使用 Vivek 的 Vcam / 捕获源过滤器构建/链接错误
- 升压program_options中的链接错误
- 使用 g++ 预处理器进行替换会导致链接错误
- 在调试配置中编译工作正常,但发布会给出链接错误
- 相邻矩阵设置链接错误
- 包含常量变量并包含在多个文件中的标头的链接错误
- C++链接错误,我理解但无法解决
- 是什么导致macOS Mojave上的GoogleTest链接错误