Monetillo
Monetillo

Reputation: 31

Cmake can't find Boost signals2

I need the component signals2 of Boost. I wrote these lines in my cmake:

find_package(Boost COMPONENTS signals2 REQUIRED)

target_link_libraries(APP PUBLIC
    Boost::signals2
)

But I got this error:

-- Could NOT find XKB (missing: XKB_LIBRARY XKB_INCLUDE_DIR) (Required is at least version "0.5.0")
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:141 (find_package):
  Could not find a package configuration file provided by "boost_signals2"
  (requested version 1.74.0) with any of the following names:

    boost_signals2Config.cmake
    boost_signals2-config.cmake

  Add the installation prefix of "boost_signals2" to CMAKE_PREFIX_PATH or set
  "boost_signals2_DIR" to a directory containing one of the above files.  If
  "boost_signals2" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:258 (boost_find_component)
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:594 (find_package)
  CMakeLists.txt:17 (find_package)

Also I tried to build the cmake with the command: cmake -DCMAKE_PREFIX_PATH=/usr/include/boost/signals2 .. But I have the same error.

I read the question: stackoverflow signals2

So I removed signals2 from find_package:

find_package(Boost REQUIRED)
target_link_libraries(APP PUBLIC
    Boost::signals2
)

But I have this error:

-- Configuring done
CMake Error at /opt/Qt/6.5.3/gcc_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:588 (add_executable):
  Target "CartoTools" links to target "Boost::signals2" but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  /opt/Qt/6.5.3/gcc_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:549 (_qt_internal_create_executable)
  /opt/Qt/6.5.3/gcc_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:741 (qt6_add_executable)
  src/CMakeLists.txt:54 (qt_add_executable)

I am sure that signals2 is in the path: /usr/include/boost/signals2. I installed boost like: sudo apt-get install libboost-all-dev

Can anyone help me? Thanks in advance!

Upvotes: 0

Views: 320

Answers (1)

Monetillo
Monetillo

Reputation: 31

I achieved to get it to compile, these are the steps I followed: First, I reinstalled the boos library. Then, I followed this tutorial to install the latest version: tutorial Finally I changed my CMake to:

find_package(Boost REQUIRED)
target_link_libraries(APP PUBLIC
    Boost::boost
)

That's all!

Upvotes: 0

Related Questions