1

I am currently having problem with my package will not compile the headers if I catkin_make my catkin_workspace.

But if I catkin_make --only-pkg-with-deps packakge it works fine?

So why am i able to compile if only compile that one independent from the rest, but when i compile everything it will not find the header file?

This is the tree structure:

pkg_a/
    ├── CMakeLists.txt
    ├── include
    │   └── pkg_a
    │       ├── pugiconfig.hpp
    │       └── pugixml.hpp
    ├── package.xml
    ├── src
        ├── src.cpp
        ├── header_to_src.h
        ├── node.cpp
        ├── pugixml.cpp
        ├── src_2.cpp
        └── header_to_src_2.h

The header i can't compile is the one inside include. pugixml.cpp cant find pugixml.hpp..

It is being included as #include <pkg_a/pugixml.hpp>

CMakeList:

cmake_minimum_required(VERSION 2.8.3)
project(pkg_a)

#Compiler flags
add_definitions(-std=c++1y)
find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  genmsg
  message_generation
  depend_1
  depend_2
)


catkin_package(
   INCLUDE_DIRS include
   LIBRARIES ${PROJECT_NAME}
   CATKIN_DEPENDS
   DEPENDS system_lib

)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

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

## Mark other files for installation (e.g. launch and bag files, etc.)
 install(
     DIRECTORY include/${PROJECT_NAME}/
#   # myfile1
#   # myfile2
   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
 )

SET(SRC_FILES
        ${SRC_FILES}
        ${CMAKE_CURRENT_SOURCE_DIR}/src/src.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/src_2.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/src/pugixml.cpp
#       ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
        CACHE INTERNAL ""
)

add_library(${PROJECT_NAME} ${SRC_FILES})

add_executable(run_${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/node.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/pugixml.cpp)
add_dependencies( ${PROJECT_NAME} depend_1_generate_messages_cpp depend_2_generate_message_cpp )
target_link_libraries(run_${PROJECT_NAME}
    ${PROJECT_NAME}
    ${catkin_LIBRARIES}
)
Carlton Banks
  • 395
  • 1
  • 6
  • 25
  • which headers ? are they the ros messages/services headers or generic ones ? – Vtik Nov 30 '16 at 09:53
  • it is the ones inside include. pugixml.cpp cant find pugixml.hpp – Carlton Banks Nov 30 '16 at 09:58
  • can you show both your CMakeLists ? It would be better to analyse ... – Vtik Nov 30 '16 at 11:15
  • oh.. there is only one.. the other one is a autosave.. but yeah one moment. – Carlton Banks Nov 30 '16 at 11:20
  • I seemed to have found the error. it was looking for the .hpp when it was compiling a different package, for some reason was the other package depending on pka_a, which makes no sense. They only share services message, which are created by depend_1 and depend_2, but the other package isn't using pugixml in anyway. I added pkg_a in the other ones dependency list and that fixed the issue. – Carlton Banks Nov 30 '16 at 12:56

0 Answers0