Ask Your Question
0

Catkin_make error: No such file or directory of a customized header file

asked 2016-05-03 09:26:43 -0500

yoo00 gravatar image

updated 2016-05-03 09:29:17 -0500

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}
)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-05-03 09:49:34 -0500

mgruhler gravatar image

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)

edit flag offensive delete link more

Comments

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!

yoo00 gravatar image yoo00  ( 2016-05-03 14:03:25 -0500 )edit

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.

mgruhler gravatar image mgruhler  ( 2016-05-04 01:48:02 -0500 )edit

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!

yoo00 gravatar image yoo00  ( 2016-05-05 10:00:00 -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

Stats

Asked: 2016-05-03 09:26:43 -0500

Seen: 5,094 times

Last updated: May 03 '16