Ask Your Question
0

header files not found even though they should be installed

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

HyEnd gravatar image

updated 2014-08-04 04:08:13 -0500

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
4

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

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

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 imagegvdhoorn ( 2014-08-04 03:34:09 -0500 )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 imageHyEnd ( 2014-08-04 04:07:54 -0500 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

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

Seen: 2,431 times

Last updated: Aug 04 '14