0

Rosanswers logo

Hello,

I encountered a catkin_make error and already spent several days of trying to solve it but I could not make it. I hope you guys have any ideas on this. I am using Ubuntu 14.04 and ROS Indigo version.

The error message I got when doing catkin_make is

fatal error: AA/AAA.hpp: No such file or directory, which is placed in a header file I made (BBB.hpp as in the below) with #include <AA/AAA.hpp>.

The following is how my source folder is organized roughly.

/devel
/build
/src
    CMakeLists.txt
    /A
        /AA
            CMakeLists.txt
            package.xml
            /src
                AAA.cpp
            /include
                AAA.hpp
    /B
        /BB
            CMakeLists.txt
            package.xml
            /src
                BBB.cpp
            /include
                BBB.hpp

A and B are directories that include corresponding multiple packages in each of them. What I have basically been trying to do is to use functions of AA package from BB package. Therefore, BB package's CMakeLists.txt and package.xml files include necessary parts to work with AA package. In the bottom, I also attached brief structure of CMakeLists of both A and B.

The weird thing is when I included #include <AA/AAA.hpp> in BBB.cpp file, it worked fine. However, when included in BBB.hpp file, I got the above error, which is fatal error: AA/AAA.hpp: No such file or directory. The followings are CMakeLists of A and B. Do you guys have any insights on this? I need to define #include <AA/AAA.hpp> in BBB.hpp file. I really appreciate your help in advance!

CMakeLists.txt of AA

cmake_minimum_required(VERSION 2.8.3)
project(AA)

set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")

find_package(catkin REQUIRED COMPONENTS )

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

include_directories( include ${catkin_INCLUDE_DIRS} )

add_library(${PROJECT_NAME} src/AA_main.cpp )

target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} )

install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} )

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

install( DIRECTORY doc DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} )

CMakeLists.txt of BB

cmake_minimum_required(VERSION 2.8.3)
project(BB)

set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")

find_package(catkin REQUIRED COMPONENTS roscpp AA )

catkin_package( INCLUDE_DIRS include LIBRARIES ${PROJECT_NAME} CATKIN_DEPENDS

DEPENDS system_lib

)

include_directories( include ${catkin_INCLUDE_DIRS} )

add_library( ${PROJECT_NAME} src/BB_main.cpp ) add_dependencies( ${PROJECT_NAME} DEPS ${${PROJECT_NAME}_EXPORTED_TARGETS}} ) target_link_libraries( ${PROJECT_NAME} ${catkin_LIBRARIES} )


Originally posted by yoo00 on ROS Answers with karma: 25 on 2016-05-03

Post score: 1

1 Answers1

0

Rosanswers logo

Well, what I see is: if you want to #include <AA/AAA.hpp> the folder structure in AA should be:

    /AA
        CMakeLists.txt
        package.xml
        /src
            AAA.cpp
        /include
            /AA
                AAA.hpp

Otherwise you need to #include <AAA.hpp>. However, why the above should work when you include it in the cpp, makes no sense for me...

(minor issue, but i guess just copy-paste-error: in CMakeLists.txt of BB: DEPS ${${PROJECT_NAME}_EXPORTED_TARGETS}} has an extra bracket at the end. And from what you post here, you'll probably not need the add_dependencies call at all)


Originally posted by mgruhler with karma: 12390 on 2016-05-03

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by yoo00 on 2016-05-03:
Thanks for your answer! But it still does not work. I also tried absolute path like #include <../../../AA/AAA.hpp> but it did not work either. I guess it is because of the CMakeLists setup but I am not sure about that. It looks really weird.. Anyway, I appreciate your tips about minor issues too!

Comment by mgruhler on 2016-05-04:
could you put a (minimal) example on GitHub and link it here? This should actually be a simple one, but I cannot see more from this.

Comment by yoo00 on 2016-05-05:
Oops. It was my bad. The error was caused by other package I made but the error was pointing to the package I described the above. That was why I was confused. Like you mentioned, it was a really simple mistake. Thanks Mig!

Matthias
  • 5,805
  • 1
  • 1
  • 1