ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Cannot include header from another package

asked 2018-03-14 20:25:56 -0500

s_lana gravatar image

updated 2018-03-20 00:40:21 -0500

jayess gravatar image

I have a package my_lib, that contains Parameters.h in he include folder, which I need to include in another package my_main . I am following this answer to do so: https://answers.ros.org/question/2019... But I get

fatal error: my_lib/Parameters.h: No such file or directory compilation terminated.

when I run catkin_make. I can see Parameters.h appear successfully in catkin_ws/install/include/my_lib after I ran catkin_make install. In my_main package i did the following:

package.xml: added

<build_depend>my_lib</build_depend>
<exec_depend>my_lib</exec_depend>

CMakeLists.txt:

find_package(catkin REQUIRED COMPONENTS
  ...(other packages used in my_main)  
  my_lib )
find_package(Boost REQUIRED COMPONENTS system) 
catkin_package(INCLUDE_DIRS include
  LIBRARIES my_main 
  CATKIN_DEPENDS ...(other packages used in my_main) my_lib
  DEPENDS system_lib)
include_directories(   include  
  ${catkin_INCLUDE_DIRS}  
  ${Boost_INCLUDE_DIRS} )
  add_executable(my_main_node src/my_main_node.cpp)
target_link_libraries(my_main_node   ${catkin_LIBRARIES} )
install(DIRECTORY
  include/${PROJECT_NAME}/   DESTINATION
  ${CATKIN_PACKAGE_INCLUDE_DESTINATION} 
  FILES_MATCHING PATTERN "*.h"   PATTERN
  ".svn" EXCLUDE )

What am I missing?

edit retag flag offensive close merge delete

Comments

Is there a difference between "my_lib" and the my2_lib that appears in your CMakeLists.txt?

JamesGiller gravatar image JamesGiller  ( 2018-03-14 21:32:24 -0500 )edit

No, that was just a typo during copying and renaming, it is all the same node. Sorry about that. Edited the post.

s_lana gravatar image s_lana  ( 2018-03-19 19:12:17 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
5

answered 2018-03-19 23:34:48 -0500

JamesGiller gravatar image

You should make sure of the following:

  1. The CMakeLists.txt of the my_lib package has catkin_package(INCLUDE_DIRS include...), include_directories(include...), and the install(...) function call inside
  2. Parameters.h is in <workspace>/src/my_lib/include/my_lib/. Notice the two occurrences of "my_lib"
  3. Relevant files in the my_main package have the correct include statement #include "my_lib/Parameters.h"
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-03-14 20:25:56 -0500

Seen: 2,019 times

Last updated: Mar 20 '18