catkin_build error:Project 'davis_ros_driver' tried to find library 'pthread'. The library is neither a target nor built/installed properly

asked 2021-12-03 20:58:36 -0600

luna wu gravatar image

melodic;cmake 3.10.0

when I run the code:wjh@wjh:~/catkin_ws/src$ catkin build davis_ros_driver

there was an error:

CMake Error at /opt/ros/melodic/share/roscpp/cmake/roscppConfig.cmake:173 (message):
      Project 'davis_ros_driver' tried to find library 'pthread'.  The library is
      neither a target nor built/installed properly.  Did you compile project
      **'roscpp'**? Did you find_package() it before the subdirectory containing its
      code is included?

I know that there are many solutions, such as downgrading the cmake version, but I have downgraded the cmake version to 3.10.0, and this error still occurs. what should I do?

Here is CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)

project(davis_ros_driver)

find_package(catkin_simple REQUIRED)

set(libcaer_DIR "/usr/lib/x86_64-linux-gnu/cmake/libcaer/")
find_package(libcaer REQUIRED)



catkin_simple()

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3")

find_package(Boost REQUIRED COMPONENTS system thread)

# make the executable
cs_add_executable(davis_ros_driver
  src/driver_node.cpp
  src/driver.cpp
)

# make the nodelet into a library
cs_add_library(davis_ros_driver_nodelet
  src/driver_nodelet.cpp
  src/driver.cpp
)

# link the executable to the necesarry libs
target_link_libraries(davis_ros_driver
  ${catkin_LIBRARIES}
  ${Boost_LIBRARIES}
  libcaer::caer
)

# link the executable to the necesarry libs
target_link_libraries(davis_ros_driver_nodelet
  ${catkin_LIBRARIES}
  ${Boost_LIBRARIES}
  libcaer::caer
)

# Install the nodelet library
cs_install()

# Install other support files for installation
install(FILES davis_ros_driver_nodelet.xml
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

# Export package
cs_export()
edit retag flag offensive close merge delete