0
$\begingroup$

Rosanswers logo

I try to catkin_make packages but it fais:

CMake Error at /opt/ros/groovy/share/genmsg/cmake/genmsg-extras.cmake:64 (message) : add_message_files() directory not found: /home/user/catkin_ws/src/msg

I can't understand why it tries to find msg files in src/msg.

catkin_ws/src/beginner_tutorials/CMakeList.txt

cmake_minimum_required(VERSION 2.8.3)
project(beginner_tutorials)

find_package(catkin REQUIRED PACKAGES roscpp rospy std_msgs message_generation)

add_message_files(FILES Num.msg)
add_service_files(FILES AddTwoInts.srv)

generate_messages(DEPENDENCIES std_msgs)

catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
DEPENDS system_lib)
    
include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(talker src/talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})
add_dependencies(talker beginner_tutorials_generate_message_cpp)

add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})
add_dependencies(listener beginner_tutorials_generate_message_cpp)

catkin_ws/src/CMakeLists.txt

    cmake_minimum_required(VERSION 2.8.3)
    project(beginner_tutorials)
    
    find_package(catkin REQUIRED PACKAGES roscpp rospy std_msgs message_generation)
    
    add_message_files(FILES Num.msg)
    add_service_files(FILES AddTwoInts.srv)
    
    generate_messages(DEPENDENCIES std_msgs)
    
    catkin_package(
    INCLUDE_DIRS include
    CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
    DEPENDS system_lib)
            
    include_directories(include ${catkin_INCLUDE_DIRS})

    add_executable(talker src/talker.cpp)
    target_link_libraries(talker ${catkin_LIBRARIES})
    add_dependencies(talker beginner_tutorials_generate_message_cpp)

    add_executable(listener src/listener.cpp)
    target_link_libraries(listener ${catkin_LIBRARIES})
    add_dependencies(listener beginner_tutorials_generate_message_cpp)

Originally posted by pelment on ROS Answers with karma: 47 on 2013-07-15

Post score: 0


Original comments

Comment by Asfandyar Ashraf Malik on 2013-07-15:
Can you please be more clear and explain more about what you are doing. Can you tell me if you sourced the file and can you output you ROS path.

Comment by pelment on 2013-07-15:
ROS_ROOT=/opt/ros/groovy/share/ros, I'm studying tutorial "Writing a Simple Publisher and Subscriber (C++)" and try to make packages. Previously I created msg and srv files in corresponding paths in beginner_tutorial.

Comment by Lucile on 2013-07-16:
Could you show your CMake file ?

Comment by pelment on 2013-07-16:
Done, Lucile

Comment by Lucile on 2013-07-16:
Did you generate your catkin workspace with catkin_init_workspace ? If so, your catkin_ws/src/CMakeLists.txt should be totally different. Anyway, you ask for Num.msg and AddTwoInts.srv in src folder and I think that's why cmake looks for them in src/msg folder.

Comment by pelment on 2013-07-16:
Yes, but I accidentally delete CMakeLists.txt in catkin_ws/src and tried to generate it using catkin_init_workspace once again, and it created that file. I can't find an example of necessary file to copy in catkin_ws/src.

Comment by Lucile on 2013-07-16:
just do another catkin_workspace then to run the publisher example.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Not sure which tutorial you were referring to, but assuming it was one of basic tutorials listed here:

directory not found: /home/user/catkin_ws/src/msg

No tutorial instructs you to create a msg directory under src directory. Instead, like this section, you're supposed to create INSIDE of a beginner_tutorials package.

catkin_ws/src/beginner_tutorials/CMakeList.txt

So yes, CMakeLists.txt you were editing is for beginner_tutorials package, and because the add_message_files macro is in there, it should make sense to you to have msg in the package too.


Originally posted by 130s with karma: 10937 on 2017-03-23

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.