Ask Your Question
0

Can't include an installed library

asked 2021-06-09 04:54:41 -0500

Bursht_ gravatar image

Hey, i started working with px4_msgs, i cloned and compiled the package properly but unfortunately i can't use the package when working on my own code with Clion: When i try to include the package It correctly link between the name and the external libraries, but can't actually include it in the code with the error that file not found.

Here is my CmakeLists file, If Someone faced this kind of issue and can help it will be awesome!!

cmake_minimum_required(VERSION 3.5) 
project(drone)

if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic -fpermissive)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(px4_msgs REQUIRED)

ament_target_dependencies(${PROJECT_NAME}
  "rclcpp"
  "rclcpp_action"
  "std_msgs"
  "sensor_msgs"
  "nav_msgs"
  "px4_msgs"
)

install(TARGETS
         ${PROJECT_NAME}
          DESTINATION
          lib/${PROJECT_NAME}
)
ament_package()
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2021-06-11 21:24:52 -0500

404RobotNotFound gravatar image

What you are probably running into is that you are using ament_target_dependencies for a target that matches your project_name (from ${PROJECT_NAME}). However, you do not build a library or add an executable to assign those dependencies to.

Later, you also try to install a target with the same ${PROJECT_NAME}, and since there is no target CMake will most likely complain about that.

If you are not building any code, I would not install anything. However, you can still set dependencies for your package, just use the ament_export_dependencies call instead.

edit flag offensive delete link more
0

answered 2021-06-10 06:40:38 -0500

Joe28965 gravatar image

You are talking about the package px4_msgs right? Did you also add it to your package.xml? If you check your package.xml file there should be a line somewhere that states:

<depend>px4_msgs</depend>

Something else you could try. You said you cloned and build the px4_msgs package yourself right? Did you make sure to source the workspace in which you build that package?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-06-09 04:54:41 -0500

Seen: 35 times

Last updated: Jun 11