1

I have been writing a small open source software using Auto-tools (C++ is the language), and have generated/installed an executive program. Some monte Carlo integration is used and the code is slow. I wish to use the gprof to improve and wish to ask how to enable gprof in it? I have tried: ./configure CFLAGS=-pg && make && sudo make install which does NOT work.

wei wang
  • 11
  • 1

1 Answers1

2

You want CXXFLAGS, not CFLAGS, since you are using C++.

Tom Tromey
  • 21,507
  • 2
  • 45
  • 63
  • Thanks a lot. I have also used the CXXFLAGS=-pg. After configure, make, make install and running the code, one output file called gmon.out is generated but I don't think this is the correct form: http://www.itkp.uni-bonn.de/~weiwang/gmon.out – wei wang Sep 24 '13 at 14:14
  • I didn't follow the link, but you can use the gprof tool to turn gmon.out into a readable format. – Tom Tromey Sep 24 '13 at 15:30
  • I have tried: gprof gmon.out but got the error: gprof: gmon.out: not in executable format – wei wang Sep 25 '13 at 08:33
  • @weiwang You must put the executable file name before the gmon file. `gprof a.out gmon.out` – Eyal Jun 15 '20 at 23:34