Ask Your Question
2

Specify gcc -pg option for catkin?

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

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

2 Answers

Sort by ยป oldest newest most voted
1

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

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 imagedeedub ( 2017-05-24 15:40:05 -0500 )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 imagepaulbovbel ( 2017-05-25 13:16:26 -0500 )edit
1

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

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 imagedeedub ( 2017-05-24 15:31:34 -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

2 followers

Stats

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

Seen: 537 times

Last updated: May 24 '17