mattdibi
mattdibi

Reputation: 821

Boost link error using Conan package manager

I encountered the following error while using the Conan version of Boost. The code compiles fine using the OS' libraries (albeit on another system).

Error output:

[  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

I already defined BOOST_LOG_DYN_LINK in my logging.h header, where I declare all my log-related macros. lib_logging.so is where the init() method is located. CMake finds all the needed libraries and work fine.

Conan configuration:

[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

Any help is appreciated.

System information:

Conan configuration:

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

Command run inside build directory (out of source build) using this as reference:

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

Upvotes: 3

Views: 1640

Answers (1)

mattdibi
mattdibi

Reputation: 821

Thanks to the questions asked by @uilianries I realized my error:

compiler.libcxx=libstdc++

This is wrong. In the installation command I added the following:

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

You can also edit the default profile at ~/.conan/profiles/default adjusting compiler.libcxx=libstdc++11.

Now everything works.

Upvotes: 4

Related Questions