I'm trying to connect the boost asio libraries to my project. But I run into a problem when configuring Imported targets and dependency information not available for Boost version

Two days googled this problem, but failed to solve. I just start working with C ++. New cmake warning about BOOST

CMake finds Boost

I understood that Boost 1.65 and 1.65.1 require CMake 3.9.3 or newer. However, updating cmake to 3.12.1 does not produce results.

Please help or tips in this matter.

System: Ubuntu 18.04 libboost: 1.65.1.0ubuntu1 cmake version 3.12.1 (updated)

Simple Project Code

#include <iostream> #include <boost/asio.hpp> int main() { std::cout << "Hello, World!" << std::endl; boost::asio::ip::tcp::iostream stream("google.com", "http"); stream << "GET /ip HTTP/1.1\r\nHost: google.com\r\nConnection: closer\n\r\n"; std::cout << stream.rdbuf(); return 0; } 

CMakeList.txt

 cmake_minimum_required(VERSION 3.12) project(ticker) set(CMAKE_CXX_STANDARD 11) set (BOOST_ROOT "/usr/lib/x86_64-linux-gnu/") set (Boost_NO_SYSTEM_PATHS ON) set (Boost_USE_MULTITHREADED ON) set (Boost_USE_STATIC_LIBS ON) set (Boost_USE_STATIC_RUNTIME OFF) set (BOOST_ALL_DYN_LINK OFF) find_package (Boost REQUIRED COMPONENTS system filesystem) if (Boost_FOUND) include_directories (SYSTEM ${Boost_INCLUDE_DIR}) endif () add_executable(ticker main.cpp) target_link_libraries (ticker ${Boost_LIBRARIES}) 

When I try to compile, I get the following

 cmake ticker -- The C compiler identification is GNU 7.3.0 -- The CXX compiler identification is GNU 7.3.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Warning at /opt/cmake-3.12.1-Linux-x86_64/share/cmake-3.12/Modules/FindBoost.cmake:577 (message): Imported targets and dependency information not available for Boost version (all versions older than 1.33) Call Stack (most recent call first): /opt/cmake-3.12.1-Linux-x86_64/share/cmake-3.12/Modules/FindBoost.cmake:959 (_Boost_COMPONENT_DEPENDENCIES) /opt/cmake-3.12.1-Linux-x86_64/share/cmake-3.12/Modules/FindBoost.cmake:1618 (_Boost_MISSING_DEPENDENCIES) CMakeLists.txt:14 (find_package) CMake Warning at /opt/cmake-3.12.1-Linux-x86_64/share/cmake-3.12/Modules/FindBoost.cmake:577 (message): Imported targets and dependency information not available for Boost version (all versions older than 1.33) Call Stack (most recent call first): /opt/cmake-3.12.1-Linux-x86_64/share/cmake-3.12/Modules/FindBoost.cmake:959 (_Boost_COMPONENT_DEPENDENCIES) /opt/cmake-3.12.1-Linux-x86_64/share/cmake-3.12/Modules/FindBoost.cmake:1618 (_Boost_MISSING_DEPENDENCIES) CMakeLists.txt:14 (find_package) CMake Error at /opt/cmake-3.12.1-Linux-x86_64/share/cmake-3.12/Modules/FindBoost.cmake:2044 (message): Unable to find the requested Boost libraries. Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers. Call Stack (most recent call first): CMakeLists.txt:14 (find_package) -- Configuring incomplete, errors occurred! See also "/home/ivan/Projects/CMakeFiles/CMakeOutput.log". 
  • one
    to install anything bypassing the package manager, if you don’t understand what you’re doing exactly - a great way to shoot yourself a leg ... - Fat-Zer
  • @ Fat-Zer Awesome! - Ivan T.

1 answer 1

Your BOOST_ROOT is obviously wrong. If you specify BOOST_ROOT, then you must have the files $ (BOOST_ROOT) /include/boost/version.hpp and $ (BOOST_ROOT) /lib/libboost_system.a (as an option $ (BOOST_ROOT) /lib/libboost_system.so).

If you have boost set from a package, then it makes sense to try not to specify BOOST_ROOT at all, cmake should in theory have to find everything itself.

If the removal of BOOST_ROOT does not help, then you must separately set BOOST_INCLUDEDIR (you must have the file $ (BOOST_INCLUDEDIR) /boost/version.hpp) and BOOST_LIBRARYDIR (I'm not sure about this name, but somehow so; there must be a file $ (BOOST_LIBRARYDIR ) /libboost_system.a or so).

In fact, there are much more necessary files there, I indicated the most obvious ones. So it does not make sense to copy these files to other folders. It is necessary to find exactly where they lie and indicate the corresponding variables.

  • Thank you for your reply. You were partly right, you had to set the last boost and set BOOST_INCLUDEDIR and BOOST_LIBRARYDIR, for example, so set (BOOST_INCLUDEDIR "/ opt / boost_1_68_0") set (BOOST_LIBRARYDIR "/ opt / boost_1_68_0 / stage / lib" - Ivan T.