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

Create two nodes in the same package

asked 2014-07-29 07:27:02 -0600

ROSkinect gravatar image

I'm using catkin package with one node (cpp file).

I want to add one more node (cpp file) in the same package but I get this error during the compilation:

-- +++ processing catkin package: 'kinectueye'
-- ==> add_subdirectory(kinectueye) CMake Error at kinectueye/CMakeLists.txt:180 (add_executable):   add_executable cannot create target "kinectueye" because another target   with the same name already exists.  The existing target is an executable   created in source directory "/home/jros/catkin_ws/src/kinectueye". See   documentation for policy CMP0002 for more details.

the package is called kinectueye and the kinectueye (the same name) is the executable of the first node.

How can I make one package with two nodes ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2014-07-29 07:35:48 -0600

Your second executable has to have a different name. Once you made sure that your two executables have different names, everything should work. For example:

add_executable(kinectueye_node src/main.cpp src/some_file.cpp src/another_file.cpp)
add_executable(kinectueye_configurator src/configurator.cpp)
edit flag offensive delete link more

Comments

Yes that's it. I forget to change kinectueye_node name.

ROSkinect gravatar image ROSkinect  ( 2014-07-29 07:46:43 -0600 )edit
1

Something I learnt the hard way is to always add a target_link_libraries line below the add_executable line for each executable. In this case that would be:

add_executable(kinectueye_node src/main.cpp src/some_file.cpp src/another_file.cpp)
target_link_libraries(kinectueye_node ${catkin_LIBRARIES})
add_executable(kinectueye_configurator src/configurator.cpp)
target_link_libraries(kinectueye_configurator ${catkin_LIBRARIES})
isaiah A gravatar image isaiah A  ( 2022-08-29 02:48:50 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-07-29 07:27:02 -0600

Seen: 7,268 times

Last updated: Jul 29 '14