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

Remove GCC optimizations

asked 2011-08-21 19:51:37 -0600

Ibrahim gravatar image

updated 2014-01-28 17:10:15 -0600

ngrennan gravatar image

Hi, I'm trying to debug an issue with some code via GDB, but some values are apparently optimized away. How can I disable compiler optimization in CMakeLists.txt? I tried doing rosbuild_remove_compiler_flags(my_executable "-O2") and then rosbuild_add_compiler_flags(my_executable "-O0") but this doesn't appear to have done anything, according to the output of make VERBOSE=1 it's still using -O2. What am I doing wrong? (the correct answer is trying to debug a ROS node using GDB, clearly...)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
7

answered 2011-08-21 20:26:52 -0600

Lorenz gravatar image

When you open the CMakeLists.txt file generated by roscreate-pkg, it should contain the following lines:

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)

Just uncomment the line set(ROS_BUILD_TYPE RelWithDebInfo) and set it to

set(ROS_BUILD_TYPE Debug)
edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-08-21 19:51:37 -0600

Seen: 817 times

Last updated: Aug 21 '11