0
$\begingroup$

Rosanswers logo

I am trying to compile the simple_marker.cpp tutorial with catkin_make in Hydro and I am getting an undefined reference error:


> CMakeFiles/simple_marker.dir/src/simple_marker.cpp.o: In function `main':
simple_marker.cpp:(.text+0x362): undefined reference to `interactive_markers::InteractiveMarkerServer::InteractiveMarkerServer(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
simple_marker.cpp:(.text+0x549): undefined reference to `interactive_markers::InteractiveMarkerServer::insert(visualization_msgs::InteractiveMarker_<std::allocator<void> > const&, boost::function<void (boost::shared_ptr<visualization_msgs::InteractiveMarkerFeedback_<std::allocator<void> > const> const&)>, unsigned char)'
simple_marker.cpp:(.text+0x567): undefined reference to `interactive_markers::InteractiveMarkerServer::applyChanges()'
simple_marker.cpp:(.text+0x5b7): undefined reference to `interactive_markers::InteractiveMarkerServer::~InteractiveMarkerServer()'
simple_marker.cpp:(.text+0x62b): undefined reference to `interactive_markers::InteractiveMarkerServer::~InteractiveMarkerServer()'
simple_marker.cpp:(.text+0x662): undefined reference to `interactive_markers::InteractiveMarkerServer::~InteractiveMarkerServer()'
simple_marker.cpp:(.text+0x6f7): undefined reference to `interactive_markers::InteractiveMarkerServer::~InteractiveMarkerServer()'
collect2: ld returned 1 exit status
make[2]: *** [/home/taylor/src/ros/catkin_ws/devel/lib/beginner_tutorials/simple_marker] Error 1
make[1]: *** [beginner_tutorials/CMakeFiles/simple_marker.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed

I think it's because of my CMakeFiles.txt:

> # %Tag(FULLTEXT)% cmake_minimum_required(VERSION 2.8.3)
> project(beginner_tutorials)
> 
> ## Find catkin and any catkin packages find_package(catkin REQUIRED
> COMPONENTS roscpp rospy std_msgs
> genmsg)
> 
> ## Declare ROS messages and services
> #add_message_files(FILES Num.msg)
> #add_service_files(FILES AddTwoInts.srv)
> 
> ## Generate added messages and services
> #generate_messages(DEPENDENCIES std_msgs)
> 
> ## Declare a catkin package catkin_package(
> ##  INCLUDE_DIRS include
> ##  LIBRARIES pick
> ##  CATKIN_DEPENDS roscpp rospy std_msgs
> ##  DEPENDS system_lib )
> 
> ## Build talker and listener include_directories(include
> ${catkin_INCLUDE_DIRS})
> 
> add_executable(talker src/talker.cpp)
> target_link_libraries(talker
> ${catkin_LIBRARIES})
> add_dependencies(talker
> beginner_tutorials_generate_messages_cpp)
> 
> add_executable(listener
> src/listener.cpp)
> target_link_libraries(listener
> ${catkin_LIBRARIES})
> add_dependencies(listener
> beginner_tutorials_generate_messages_cpp)
> 
> add_executable(simple_marker
> src/simple_marker.cpp)
> target_link_libraries(simple_marker
> ${catkin_LIBRARIES})
> add_dependencies(simple_marker
> beginner_tutorials_generate_messages_cpp)
> 
> # %EndTag(FULLTEXT)%

I am able to run the basic controls tutorial in rviz, but I did not compile it, just installed the package and ran: rosrun interactive_marker_tutorials basic_controls

Can someone let me know if it is a CMakeLists thing or am I way off. I have not been able to find a CMakeLists example for an interactive marker node.

Thanks


Originally posted by TFinleyosu on ROS Answers with karma: 385 on 2013-12-04

Post score: 0


Original comments

Comment by karen.rod on 2020-08-30:
I have exactly the same error and I could not solve it with these recommendations. Has anyone else had this same error?

Comment by Kansai on 2021-03-09:
I have the same error but my CMakelist.txt is so big and complicated that the recommendations do not work at all :(

Comment by Turuu on 2023-04-14:
Yeah, I'm also getting the same error again and again. As a beginner, it is too hard to figure out what is really going on.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

It appears you don´t have the dependency on the interactive_markers package defined in your package. For an example of how to do that, you can look at the turtlebot_interactive_markers package, which is a pretty simple example of a package using interactive_markers in catkin. The relevant parts are in the CMakeLists.txt and package.xml files.


Originally posted by Stefan Kohlbrecher with karma: 24361 on 2013-12-04

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by TFinleyosu on 2013-12-06:
Thank you! I had been looking for an example and just couldn't find it. I'll respond when I get a results.

Comment by TFinleyosu on 2013-12-11:
That did the trick! I was able to update my CMakeLists with the following:

find_package(catkin REQUIRED COMPONENTS pcl_conversions pcl_ros roscpp sensor_msgs visualization_msgs interactive_markers )

I added the "visualization_msgs" and "interactive_markers" and it worked. Thanks.

Comment by tangeni on 2020-10-13:
Thanks, @Stefan. This solved my problem too.

$\endgroup$

Your Answer

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