Cannot find the header file (msg)

asked 2019-07-03 08:23:49 -0500

EdwardNur gravatar image

Hi,

I have a custom built rosmsg but for some reason, I cannot include its header as my IDE cannot locate it. Here is my CMakeLists of the package that uses this rosmsg (called gslam_msgs):

cmake_minimum_required(VERSION 2.8.3)
project(gslam)

add_compile_options(-std=c++17)

find_package(catkin REQUIRED COMPONENTS
             gslam_msgs
             std_msgs
                 sensor_msgs
                 geometry_msgs
                   roscpp
             tf2_ros
)
find_package(Eigen3 REQUIRED)



catkin_package(
   INCLUDE_DIRS
        include
   CATKIN_DEPENDS
        roscpp
   LIBRARIES
        factorgraph  

)

include_directories(
  include
  ${Eigen3_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
)

find_package(GTSAMCMakeTools)
# Find GTSAM components
find_package(GTSAM REQUIRED) # Uses installed package
include_directories(${GTSAM_INCLUDE_DIR})




install(DIRECTORY include/${PROJECT_NAME}/
        DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
        FILES_MATCHING PATTERN "*.h"
        PATTERN ".svn" EXCLUDE)

add_library(factorgraph  
     src/factorgraph.cpp
) 
target_link_libraries(factorgraph
   gtsam
  ${catkin_LIBRARIES}
)

add_executable(main src/graph.cpp)
target_link_libraries(main
   factorgraph
   gtsam
  ${catkin_LIBRARIES}
)

And this is how I try to include:

#include "gslam_msgs/PoseNode.h"

And the CMakeL for the gslam_msgs:

cmake_minimum_required(VERSION 2.8.3)
project(gslam_msgs)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

## 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
        message_generation
        std_msgs
        sensor_msgs
        geometry_msgs
        )



## Generate messages in the 'msg' folder
add_message_files(
        FILES
        BetweenFactor.msg
        Path2D.msg
        PoseNode.msg
)

## Generate added messages and services with any dependencies listed here
generate_messages(
        DEPENDENCIES
        std_msgs
        sensor_msgs
        geometry_msgs

)


catkin_package(
        #  INCLUDE_DIRS include
        #  LIBRARIES maxon_epos_msgs
        CATKIN_DEPENDS message_runtime std_msgs
        #  DEPENDS system_lib
)

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

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
        # include
        ${catkin_INCLUDE_DIRS}
)
edit retag flag offensive close merge delete

Comments

Have you successfully run catkin_make since you created these custom messages to build the headers?

PeteBlackerThe3rd gravatar imagePeteBlackerThe3rd ( 2019-07-03 08:46:12 -0500 )edit

@PeteBlackerThe3rd I cannot run catkin_make as I am getting the error that no such file exist

EdwardNur gravatar imageEdwardNur ( 2019-07-03 09:38:07 -0500 )edit

@PeteBlackerThe3rd Ok quick update. I have deleted the build and devel folders and run catkin_make from the terminal = no errors. Then I have tried to build the package from my CLion and getting the same error as above

EdwardNur gravatar imageEdwardNur ( 2019-07-03 09:40:06 -0500 )edit

Then the problem should be with CLion, since afaik CLion has its own CMakeLists.txt files and it may need some modifications it what it tries to build!

kosmastsk gravatar imagekosmastsk ( 2019-07-03 10:41:55 -0500 )edit