ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Adding Executables, Dependencies and Target Link Libraries - Client Example

asked 2015-10-30 17:32:10 -0500

d7x gravatar image

updated 2015-10-30 18:54:47 -0500

Mani gravatar image

I'm running Indigo on Ubuntu 14.04 and in the tutorial [ http://wiki.ros.org/actionlib_tutoria... ], under section 1.3, CMakeLists.txt is modified to add Executables, Dependencies and Target Link Libraries. Since this builds on the work of the SimpleActionServer, should these be ADDED to this file or should they replace what was used for the prior lesson:

http://wiki.ros.org/actionlib_tutoria...

add_executable(fibonacci_server src/fibonacci_server.cpp)

target_link_libraries(
  fibonacci_server
  ${catkin_LIBRARIES}
)

add_dependencies(
  fibonacci_server
  ${learning_actionlib_EXPORTED_TARGETS}
)

I can get the tutorial for the client working fine when I replace the above dependencies, link libraries and executables. But, the directions seem to say ADD the new dependencies, link libraries and executables to what was used for the client example. If that is the case, how do you add multiple dependencies, executables and link libraries. I haven't found the correct syntax.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-10-30 19:21:39 -0500

ahendrix gravatar image

Yes; you should be adding to the CMakeLists from the previous tutorial.

You shouldn't be trying to combine multiple statements from the different tutorials.

For example, each call to add_executable() in cmake defines a new executable that you're trying to compile, and you want to compile each tutorial, so you should have two separate calls to add_executable()

Your final CMakeLists should look something like:

cmake_minimum_required(VERSION 2.8.3)
project(learning_actionlib)

find_package(catkin REQUIRED COMPONENTS roscpp actionlib actionlib_msgs)
find_package(Boost REQUIRED COMPONENTS system)

add_action_files(
  DIRECTORY action
  FILES Fibonacci.action
)

generate_messages(
  DEPENDENCIES actionlib_msgs std_msgs
)

catkin_package(
  CATKIN_DEPENDS actionlib_msgs
)

include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})

add_executable(fibonacci_server src/fibonacci_server.cpp)

target_link_libraries(
  fibonacci_server
  ${catkin_LIBRARIES}
)

add_dependencies(
  fibonacci_server
  ${learning_actionlib_EXPORTED_TARGETS}
)

add_executable(fibonacci_client src/fibonacci_client.cpp)

target_link_libraries( 
  fibonacci_client
  ${catkin_LIBRARIES}
)

add_dependencies(
  fibonacci_client
  ${learning_actionlib_EXPORTED_TARGETS}
)
edit flag offensive delete link more

Comments

Perfect, thanks for explaining this.

d7x gravatar image d7x  ( 2015-10-30 21:27:42 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-10-30 17:32:10 -0500

Seen: 619 times

Last updated: Oct 30 '15