Ask Your Question

How to build release version of ROS node

asked 2018-12-25 14:34:04 -0500

AutoCar gravatar image

I have written my own ROS node, it works well. But I am not sure if the exe is debug version or release version? How can I find out? What changes I need to make to CMakefile.txt to build release version ROS node?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2019-01-04 13:43:43 -0500

tfoote gravatar image

You can set the build type in the CMake but it's not recommended to hard code the build type in the CMakeLists.txt but to pass it on the command line when you build. This way if you want to build with debug you just change your invocation instead of having to change the code. This is particularly important if you have a large workspace with lots of packages. If you wanted to change the build type you'd have to modify every package's CMakeLists.txt which is a pain and messy if you have other changes nearby.

cmake -DCMAKE_BUILD_TYPE=Release ..

Note that you can pass this to

catkin: -DCMAKE_BUILD_TYPE=Release

catkin_tools or colcon: --cmake-args -DCMAKE_BUILD_TYPE=Debug

Note that if you don't set a build type that's not debug or release in CMake

edit flag offensive delete link more

answered 2019-01-04 04:29:36 -0500

juanlu gravatar image

updated 2019-01-04 07:16:27 -0500

To compile your code in release you have to add this flag to the CMakeLists, taken from here:

  set(CMAKE_BUILD_TYPE Release)

Finding out if the compiled files are in debug or release is a bit tricky, take a look at this question for starters.

edit flag offensive delete link more



Wouldn't set(CMAKE_BUILD_TYPE Release) (or RelWithDebInfo) be more portable and correct (but be careful with just setting it)? Without the CMAKE_BUILD_TYPE being set, CMAKE_CXX_FLAGS_RELEASE will not be used.

gvdhoorn gravatar image gvdhoorn  ( 2019-01-04 04:34:29 -0500 )edit

You are right! Ill edit my answer

juanlu gravatar image juanlu  ( 2019-01-04 05:30:09 -0500 )edit

Perhaps something like this would be better, as an unconditional set(..) will make it impossible to configure the build type from the command line.

gvdhoorn gravatar image gvdhoorn  ( 2019-01-04 06:51:08 -0500 )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



Asked: 2018-12-25 14:34:04 -0500

Seen: 1,227 times

Last updated: Jan 04 '19