Ask Your Question
1

undefined reference to `ros::console::initializeLogLocation()' in turtlebot_arm_block_manipulation package

asked 2015-02-17 04:10:39 -0600

est_CEAR gravatar image

updated 2015-02-23 08:30:19 -0600

Hi,

I added #include <ros/console.h> in the header files on top of my .cpp, but I still get this error :

undefined reference to `ros::console::initializeLogLocation()'

What shall I add in CMakeLists.txt, in catkin_package, or in package.xml? I use ROS Hydro.

Thanks

edit retag flag offensive close merge delete

Comments

1

Please include your current CMakeLists.txt and package.xml. Remove all the boilerplate comments from it before posting.

(but most likely you are missing a dependency on roscpp)

gvdhoorn gravatar imagegvdhoorn ( 2015-02-22 06:59:05 -0600 )edit

Hi, thanks. As you can read, I included roscpp...

est_CEAR gravatar imageest_CEAR ( 2015-02-22 07:16:27 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-02-23 08:05:57 -0600

est_CEAR gravatar image

Thanks gvdhoorn

The missing dependencies were in the CMakeLists.txt In the turtlebot_arm_block_manipulation/CMakeLists, two scripts are commented and not compiled to executables, with a "TODO" mention. I uncommented the declaration without adding the target_link_libraries(..) and add_dependencies(...) that are needed. It was like that :

# TODO need review
# add_executable(block_manipulation test/block_manipulation.cpp)
# add_executable(block_manipulation_actions test/block_manipulation_actions.cpp)

Should be like that :

add_executable(block_manipulation test/block_manipulation.cpp src/cear_move_gripper.cpp)
target_link_libraries(block_manipulation ${catkin_LIBRARIES} ${PCL_LIBRARIES})
add_dependencies(block_manipulation turtlebot_arm_block_manipulation_gencpp)

add_executable(block_manipulation_actions test/block_manipulation_actions.cpp src/cear_move_gripper.cpp)
target_link_libraries(block_manipulation_actions ${catkin_LIBRARIES} ${PCL_LIBRARIES})
add_dependencies(block_manipulation_actions turtlebot_arm_block_manipulation_gencpp)

Note that "src/cear_move_gripper.cpp" is a node I implemented to action the gripper.

edit flag offensive delete link more

Comments

If somebody can correct it in Github, it would be nice for the next users :)

est_CEAR gravatar imageest_CEAR ( 2015-02-26 08:16:26 -0600 )edit
0

answered 2015-02-22 07:47:39 -0600

gvdhoorn gravatar image

updated 2015-02-22 07:55:04 -0600

tl;dr: find_package(..) calls do not accumulate results, but overwrite. You are calling find_package(catkin ..) twice, and only the results of the second invocation end up in catkin_INCLUDE_DIRS & friends. So info on roscpp (and std_mgs) is not actually stored.


find_package(catkin REQUIRED COMPONENTS roscpp std_msgs)
find_package(catkin REQUIRED actionlib actionlib_msgs interactive_markers pcl_ros roscpp visualization_msgs arbotix_msgs moveit_core moveit_ros_planning_interface genmsgs)

Your problem is actually a CMake issue: you ask CMake to find_package(..) something called catkin twice.

First with COMPONENTS set to roscpp std_msgs, and then another time with a whole new list of things for CMake to look for (using the catkin find script (or configure file)).

That doesn't work, as CMake will store the result of the first find_package(catkin ..) in variables prefixed with catkin_..., and then the result of the second find_package(catkin ..) in variables prefixed with catkin_... But you already had variables prefixed with catkin_.., so the first ones are actually overwritten (and the results for roscpp std_msgs are lost).

In order to fix this, just append the list after COMPONENTS from your second find_package(..) call to the first.


Edit: also:

link_directories(${catkin_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${PCL_LIBRARY_DIRS})

This is almost never necessary in a (properly setup) catkin/CMake project. All entries in (catkin, Boost, PCL)_LIBRARIES are supposed to be absolute paths. Explicitly calling link_directories(..) can actually cause strange library resolving errors.

edit flag offensive delete link more

Comments

1

Well, your CMakeLists.txt is incomplete: it doesn't contain any add_executable(..) or target_link_libraries(..) statements. Are you sure you are linking your nodes against catkin_LIBRARIES for instance? See Executable_Targets.

gvdhoorn gravatar imagegvdhoorn ( 2015-02-23 07:28:47 -0600 )edit

Right, thanks! The files were commented and there was a "TODO" mention so I implemented them but didn't care how they were compiled in the CMakeLists.txt The target_link_libraries and catkin_dependencies were missing. Can you update your answer?

est_CEAR gravatar imageest_CEAR ( 2015-02-23 07:56:53 -0600 )edit

How would I update my answer? If you don't declare any executables, things will not work. Catkin/CMake cannot magically know what you want it to do.

gvdhoorn gravatar imagegvdhoorn ( 2015-02-23 08:10:40 -0600 )edit

look at my answer. I explained. Thanks

est_CEAR gravatar imageest_CEAR ( 2015-02-23 08:28:32 -0600 )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

1 follower

Stats

Asked: 2015-02-17 04:10:39 -0600

Seen: 4,694 times

Last updated: Feb 23 '15