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

Specify gcc -pg option for catkin?

asked 2017-05-19 23:55:58 -0600

deedub gravatar image

Hi all,

I am working on a project to do some performance profiling on amcl. To do this, I want to use gprof. To use gprof, I need to compile amcl with the -pg option for gcc. How can I do this in the catkin environment? Is this the right approach?

Bonus question: I don't really want to profile all of the navigation package, only amcl. How can I break amcl out of the navigation package so that I am only profiling amcl?

thanks in advance!

dw

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2017-05-24 12:15:25 -0600

paulbovbel gravatar image

The preferred approach is to modify the package's CMakeLists.txt to change the compile options:

set_directory_properties(PROPERTIES COMPILE_OPTIONS "-pg")

This will modify the compile options for the whole package, but won't bleed into other packages accidentally due to cmake include.

There's also ways to modify compile options per target (so just for one library or executable), see https://stackoverflow.com/questions/2...

edit flag offensive delete link more

Comments

Thanks very much for your answer. Just to clarify, this is preferable specifically because it won't bleed into other packages accidentally?

deedub gravatar image deedub  ( 2017-05-24 15:40:05 -0600 )edit
1

Correct. catkin_make will actually magically combine all your package cmakes into one. catkin_make_isolated or the very awesome catkin-tools will properly isolate packages, making set(CMAKE_CXX_FLAGS ...) slightly more tenable.

paulbovbel gravatar image paulbovbel  ( 2017-05-25 13:16:26 -0600 )edit
1

answered 2017-05-21 19:42:56 -0600

allenh1 gravatar image

You can simply add it to the CMakeLists.txtfile.

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
edit flag offensive delete link more

Comments

I used this snippet on the amcl/CMakeLists.txt file and it worked perfectly. Thanks!

deedub gravatar image deedub  ( 2017-05-24 15:31:34 -0600 )edit
0

answered 2020-10-08 03:59:33 -0600

AlexisTM gravatar image

updated 2020-10-08 04:00:13 -0600

Another way to run it over the whole workspace without changing the CMakeLists.txt is to use command-line arguments:

catkin build  --cmake-args -DCMAKE_C_FLAGS="-pg" -DCMAKE_CXX_FLAGS="-pg" --
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-05-19 23:55:58 -0600

Seen: 1,676 times

Last updated: Oct 08 '20