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

header files not found even though they should be installed

asked 2014-08-03 04:42:07 -0600

HyEnd gravatar image

updated 2014-08-04 04:08:13 -0600

I created a package A which only contains a header file to use in some other packages. But when trying to use the header in project B I always get the error "File not found". I found some questions here addressing the problem as "install issue". But I have the installation in my CMakeLists.txt of package A.

I also included ${CATKIN_INCLUDE_DIRS} in project B, but it still does not find the header file.

CMakeLists.txt of A:

cmake_minimum_required(VERSION 2.8.3)
project(A)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  geometry_msgs
  ndt_map
  roscpp
  rospy
  std_msgs
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
  ${catkin_INCLUDE_DIRS}
  include
)

#############
## Install ##
#############

## Mark cpp header files for installation
 install(DIRECTORY include/${PROJECT_NAME}/
   DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
   FILES_MATCHING PATTERN "*.h"
   PATTERN ".svn" EXCLUDE
 )

important part of CMakeLists.txt of project B:

find_package( catkin REQUIRED COMPONENTS
   A
)
include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2014-08-03 16:25:25 -0600

ahendrix gravatar image

In addition to installing header files, you also need to use the catkin_package command to inform other packages about where to find your header files when building from source in the same workspace:

catkin_package(INCLUDE_DIRS include)
edit flag offensive delete link more

Comments

1

In addition to this: OP used find_package(A), but there is no corresponding include_directories([..] ${A_INCLUDE_DIRS} [..]). Only find_package() is not enough. Alternatively, list A in find_package(catkin COMPONENTS [..] A [..]). Only then you rely on catkin_INCLUDE_DIRS.

gvdhoorn gravatar image gvdhoorn  ( 2014-08-04 03:34:09 -0600 )edit

thank you both for your answers, @ahendrix approach was enough to solve the problem. @gvdhoom I actually used the "catkin COMPONENTS" tag, but I'm afraid I forgot to mention that in my question...

HyEnd gravatar image HyEnd  ( 2014-08-04 04:07:54 -0600 )edit

Had problem that no headers were found. Adding include_directories(include ${catkin_INCLUDE_DIRS}) fixed it thanks

Combinacijus gravatar image Combinacijus  ( 2021-08-08 08:43:51 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-08-03 04:42:07 -0600

Seen: 5,586 times

Last updated: Aug 04 '14