Robotics StackExchange | Archived questions

Why do we need to Install a node Executable

Hello,

I am newbie in ROS and CMake (catkin) thing. I have a cmake, in which a node is added as executable:

add_executable(${PROJECT_NAME}_node src/implementation.cpp src/NodeName2_node.cpp)

So, I can run this node from launch file of other projects.

Later in Cmake, he also installed that executable by following statements:

install(TARGETS ${PROJECT_NAME}_node ${PROJECT_NAME}
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

I did not understand why he needed to install those executable. Can someone please explain this.

Asked by tonyParker on 2018-11-02 09:59:28 UTC

Comments

Answers

The first line you mentioned tells the build system that a c++ executable needs to be compiled and linked. If this binary is built okay it will exists in the development part of the package. This is all you need if you're making your own nodes and sharing your source code with others.

However if you want to share your compiled work with others you'll need to create an install folder with everything they will need to run your code but not your source code. This is what is being defined by the second set of lines. You only need this section if you're going to share your package but keep the source code private or produce your own debian packages for apt-get etc.

Hope this helps clear this up.

Asked by PeteBlackerThe3rd on 2018-11-02 12:40:26 UTC

Comments