Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: Profiling problems

  1. #1
    Join Date
    Jul 2006
    Posts
    7
    Thanks
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Profiling problems

    Hi,
    I've just written my small app, but want to profile it in order to optimize it.
    I tried adding -pg flags in the CFLAGS, CXXFLAGS, LIBS and in the make targets, but no gmon.out is created. I googled the problem, but found no answer .

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Profiling problems

    You should add the flag in your project file to the variable called QMAKE_CXXFLAGS_DEBUG.

  3. The following user says thank you to wysota for this useful post:

    Tindor (24th December 2006)

  4. #3
    Join Date
    Jul 2006
    Posts
    7
    Thanks
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Profiling problems

    Well, I added it, but it stil does not create gmon.out.
    I also noticed this in the Makefile:
    Qt Code:
    1. DEFINES = -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
    To copy to clipboard, switch view to plain text mode 
    And when I remove it and try "make" it's put in there again, maybe that's the problem.

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Profiling problems

    Looks like you are compiling a release version. Also, you must compile and link it with the corresponding profiling flags.

    QMAKE_CXXFLAGS_DEBUG *= -pg
    QMAKE_LFLAGS_DEBUG *= -pg
    $ qmake -config debug
    $ make
    J-P Nurmi

  6. The following 2 users say thank you to jpn for this useful post:

    Tindor (24th December 2006), vfernandez (3rd January 2007)

  7. #5
    Join Date
    Jul 2006
    Posts
    7
    Thanks
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Profiling problems

    Well, now I can debug the program with gdb , but still no gmon.out is created

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Profiling problems

    Does the compilation run with -pg compiler flags? Did you recreate the Makefile after modyfiing the project file?

  9. The following user says thank you to wysota for this useful post:

    Tindor (24th December 2006)

  10. #7
    Join Date
    Jul 2006
    Posts
    7
    Thanks
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Profiling problems

    It does, here's the code:
    g++ -c -pipe -g -pg -pg -Wall -W -D_REENTRANT -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4/QtOpenGL -I/usr/include/qt4 -I. -I/usr/include -I. -I. -o main.o main.cpp
    Also, the makefile is supposed to be regenerated afer running qmake, am I wrong?
    Last edited by jacek; 24th December 2006 at 00:11. Reason: changed [code] to [quote]

  11. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Profiling problems

    How do you start that application? gmon.out will be generated in the current directory and only if your application exits cleanly.

    Check if you can generate gmon.out for this small example:
    Qt Code:
    1. #include <QApplication>
    2. #include <QPushButton>
    3.  
    4. int main( int argc, char **argv )
    5. {
    6. QApplication app( argc, argv );
    7.  
    8. QPushButton b( "Close" );
    9. QObject::connect( &b, SIGNAL( clicked() ), &b, SLOT( close() ) );
    10. b.show();
    11.  
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (2.00a) nie gru 24 01:16:45 2006
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. TARGET +=
    7. DEPENDPATH += .
    8. INCLUDEPATH += .
    9.  
    10. CONFIG += debug
    11. QMAKE_CXXFLAGS_DEBUG *= -pg
    12. QMAKE_LFLAGS_DEBUG *= -pg
    13.  
    14. # Input
    15. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 

    $ ls
    main.cpp prof.pro
    $ qmake
    $ make
    ...
    $ ls
    main.cpp main.o Makefile prof prof.pro
    $ ./prof
    $ ls
    gmon.out main.cpp main.o Makefile prof prof.pro

  12. The following 2 users say thank you to jacek for this useful post:

    lit-uriy (24th January 2009), Tindor (24th December 2006)

  13. #9
    Join Date
    Jul 2006
    Posts
    7
    Thanks
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Profiling problems

    Oops, I'm sorry I made you write the code. I've forgotten that I had to run the app in order to get a gmon.out.
    Thank you very much !

  14. #10
    Join Date
    Jun 2007
    Posts
    52
    Thanks
    6

    Default Re: Profiling problems

    I am having a similar issue. My program is a very large program and I created my own shared libraries, but when I try to compile them with the -pg flag set in QMAKE_CXXFLAGS_DEBUG and in QMAKE_LFLAGS_DEBUG and then run it I don't get the gmon.out.

    It is exiting normally and I have it set so that all the shared libraries are building with the flags. Any ideas?

  15. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Profiling problems

    This is a known issue with gprof. Please google around for using gprof with shared object files or use a different profiler such as Valgrind's callgrind tool.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #12
    Join Date
    Jun 2007
    Posts
    52
    Thanks
    6

    Default Re: Profiling problems

    gprof is the reason I don't get the gmon.out file? I thought that was part of the gcc

  17. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Profiling problems

    It's part of gcc but it's made for gprof. You'll find solutions much quicker if you google for "gprof and shared object files" than for "gcc and shared object files". And the file should be generated. It might be meaningless but it should get generated. Are you sure you linked with the -pg flag as well?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  18. #14
    Join Date
    Jun 2007
    Posts
    52
    Thanks
    6

    Default Re: Profiling problems

    Yes it is in the linker string as well...I am trying to get it to work with shared libraries, but I can't get it to work with just a single executable either.

  19. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Profiling problems

    Check the actual compilation line (not what's inside qmake project file) if -pg is there for both compiling and linking phase. Also be sure to compile with -g (debug).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  20. #16
    Join Date
    Jun 2007
    Posts
    52
    Thanks
    6

    Default Re: Profiling problems

    I think I found the issue, I just don't know how to fix it. gcc -pg main.c works fine but g++ -pg main.cpp compiles but doesn't output a gmon.out file. For some reason a C file will give us a profile but a C++ file wont.

  21. #17
    Join Date
    Jun 2007
    Posts
    52
    Thanks
    6

    Default Re: Profiling problems

    Since this no longer seems to be a Qt issue I have posted the question in the google groups gnu.g++.help section. Thanks for the help

  22. #18
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Profiling problems

    It must not be that simple. It works just fine for me. Try Jacek's example.
    J-P Nurmi

  23. #19
    Join Date
    Jun 2007
    Posts
    52
    Thanks
    6

    Default Re: Profiling problems

    I tried his example...word for word and it doesn't produce a gmon.out file. the last line of the make output says....
    Warning: consider linking with '-static' as system libraries with profiling support are only provided in archive format.

    Currently Qt is built dynamically because the project I am on can't be built statically.

  24. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Profiling problems

    Quote Originally Posted by abbapatris View Post
    I tried his example...word for word and it doesn't produce a gmon.out file. the last line of the make output says....
    Warning: consider linking with '-static' as system libraries with profiling support are only provided in archive format.
    This only means you won't get profiling information from libraries such as libc which is good for you. Run the resulting application and you should get a gmon.out file.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Problems customizing QSlider
    By Antrax in forum Qt Programming
    Replies: 13
    Last Post: 20th December 2011, 07:00
  2. Problems with Unicode(UTF8)
    By cristiano in forum Qt Programming
    Replies: 15
    Last Post: 5th December 2006, 12:33
  3. QGLWidget Problems
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 2nd October 2006, 22:06
  4. Problems
    By euthymos in forum Installation and Deployment
    Replies: 2
    Last Post: 13th June 2006, 19:11
  5. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.