emigrand
23rd February 2012, 20:05
Hi!
First of all my background: I am a biologist interested in programming, not a programmer. Nonetheless I worked my way into C++ and Qt in order to write a programm which plots A/D converter data, sets triggers etc. for a scientific application. After installing Qt and Qwt, which was very laborious for me, I managed to produce a programm which works suprisingly well. But when having a closer look at the log-file where adc data is exported to, I realised a sample interval of >= 4 ms, which is not enough for our applications (at least 0.1 ms should be reached). So now my idea was to perform a profiling in order to find the bottleneck in my code - and this is where the actual problem starts!
I quickly stumbled over a profiler called callgrind (or valgrind) which would do the job for me - but it seems to be only for linux. I couldn't find any other freeware which seems to work well with Qt. When I tried "verysleepy", I couldn't find my functions in the statistics. Anyway, more and more I realized that I have to build a debug version of my code in order to use any profiling software(!?). But I'm not sure if this is possible with my installation of Qt/Qwt. I was just happy when I got it running, but didn't spend any attention on how I build Qt/Qwt or what this means for debugging, respectively. To give you an idea of how I installed Qt/Qwt, please have a look at this protocoll, which I luckily wrote in order to reproduce installation:
Download qt-sdk-win-opensource-2010.05.exe from http://qt.nokia.com/downloads/sdk-windows-cpp
This contains mingw, the Qt libraries version 4.7.0 and Qt Creator IDE version 2.0.1
Install this C:\Qt\2010.05\
Download qt-creator-2.0.1-src.zip
Unpack this to C:\qt-creator-2.0.1-src\
Add the line "CONFIG += release" to qtcreator.pro (after "CONFIG += ordered"), just to be sure
Create a new folder C:\qt-creator-2.0.1-build\
Enter the "Qt Command Prompt" via the Start menu and type:
cd C:\qt-creator-2.0.1-build
qmake ..\qt-creator-2.0.1-src\qtcreator.pro
mingw32-make release
Create new system environment variable QTDIR and assign value C:\Qt\2010.05\qt
Add C:\Qt\2010.05\mingw\bin to system PATH (to make Mingw available. If you install Mingw seperately, than adjust path accordingly)
Add %QTDIR%\bin to system PATH (avoids copying of required Qt-dlls)
Download the newest version of qwt (6.0.1 ?) and unzip to C:\qwt-6.0.1
Add the line "CONFIG += release" to qwt.pro (after "CONFIG += ordered")
Follow qwt install manual. Briefly:
Open command shell, cd to Qwt-folder and type
qmake qwt.pro -spec win32-g++ -r CONFIG+=release
mingw32-make
mingw32-make install
Type qmake -set QMAKEFEATURES C:/Qwt-6.0.1 so that QT can find the qwt.prf file
Copy qwt_designer_plugin.dll to C:\Qt\2010.05\qt\plugins\designer\
Copy qwt.dll to C:\qt-creator-2.0.1-build\bin\
Start C:\qt-creator-2.0.1-build\bin\qtcreator.exe
Create new project
Change project to release mode (left panel, near to bottom)
Add following lines to every .pro file:
CONFIG += qwt (essential, points to qwt.prf file)
CONFIG += release (probably essential)
INCLUDEPATH += C:\Qwt-6.0.1\src (probably essential)
DEFINES += QT_DLL \ (not sure)
QWT_DLL (not sure)
If QWT-Wigets are not visible, try one or more of following things (not sure about their necessity):
Create new system environment variable INCLUDE and assign value %QTDIR%\include
Create new system environment variable LIB and assign value %QTDIR%\lib
Create new system environment variable QWTDIR and assign value C:\qwt-6.0.1
Create new system environment variable QMAKESPEC and assign value win32-g++
Enter the "Qt Command Prompt" via the Start menu and type:
qmake -set Q_PLUGIN_PATH C:\qwt-6.0.1\designer\plugins\designer
Here are are questions:
Am I right with my assumption, that I installed Qt and Qwt in release mode?
Does this mean, that I cannot build debug versions of my application?
I have got the debug button, so do I have a debugger which was provided with Qt-SDK (like gdb or so)?
Why does the program not stop at breakpoints?
Why does is say "process couldn't be started" when I choose debug instead of release?
What must my .pro file look like in order to debug or build a debug version? Do I have to add something like config += debug?
If I am on the wrong track, where do I have to start to get to my goal (find the bottlenecks)?
Any help would be appreciated. Please respect my background, so that I can understand you!
Thank you!
First of all my background: I am a biologist interested in programming, not a programmer. Nonetheless I worked my way into C++ and Qt in order to write a programm which plots A/D converter data, sets triggers etc. for a scientific application. After installing Qt and Qwt, which was very laborious for me, I managed to produce a programm which works suprisingly well. But when having a closer look at the log-file where adc data is exported to, I realised a sample interval of >= 4 ms, which is not enough for our applications (at least 0.1 ms should be reached). So now my idea was to perform a profiling in order to find the bottleneck in my code - and this is where the actual problem starts!
I quickly stumbled over a profiler called callgrind (or valgrind) which would do the job for me - but it seems to be only for linux. I couldn't find any other freeware which seems to work well with Qt. When I tried "verysleepy", I couldn't find my functions in the statistics. Anyway, more and more I realized that I have to build a debug version of my code in order to use any profiling software(!?). But I'm not sure if this is possible with my installation of Qt/Qwt. I was just happy when I got it running, but didn't spend any attention on how I build Qt/Qwt or what this means for debugging, respectively. To give you an idea of how I installed Qt/Qwt, please have a look at this protocoll, which I luckily wrote in order to reproduce installation:
Download qt-sdk-win-opensource-2010.05.exe from http://qt.nokia.com/downloads/sdk-windows-cpp
This contains mingw, the Qt libraries version 4.7.0 and Qt Creator IDE version 2.0.1
Install this C:\Qt\2010.05\
Download qt-creator-2.0.1-src.zip
Unpack this to C:\qt-creator-2.0.1-src\
Add the line "CONFIG += release" to qtcreator.pro (after "CONFIG += ordered"), just to be sure
Create a new folder C:\qt-creator-2.0.1-build\
Enter the "Qt Command Prompt" via the Start menu and type:
cd C:\qt-creator-2.0.1-build
qmake ..\qt-creator-2.0.1-src\qtcreator.pro
mingw32-make release
Create new system environment variable QTDIR and assign value C:\Qt\2010.05\qt
Add C:\Qt\2010.05\mingw\bin to system PATH (to make Mingw available. If you install Mingw seperately, than adjust path accordingly)
Add %QTDIR%\bin to system PATH (avoids copying of required Qt-dlls)
Download the newest version of qwt (6.0.1 ?) and unzip to C:\qwt-6.0.1
Add the line "CONFIG += release" to qwt.pro (after "CONFIG += ordered")
Follow qwt install manual. Briefly:
Open command shell, cd to Qwt-folder and type
qmake qwt.pro -spec win32-g++ -r CONFIG+=release
mingw32-make
mingw32-make install
Type qmake -set QMAKEFEATURES C:/Qwt-6.0.1 so that QT can find the qwt.prf file
Copy qwt_designer_plugin.dll to C:\Qt\2010.05\qt\plugins\designer\
Copy qwt.dll to C:\qt-creator-2.0.1-build\bin\
Start C:\qt-creator-2.0.1-build\bin\qtcreator.exe
Create new project
Change project to release mode (left panel, near to bottom)
Add following lines to every .pro file:
CONFIG += qwt (essential, points to qwt.prf file)
CONFIG += release (probably essential)
INCLUDEPATH += C:\Qwt-6.0.1\src (probably essential)
DEFINES += QT_DLL \ (not sure)
QWT_DLL (not sure)
If QWT-Wigets are not visible, try one or more of following things (not sure about their necessity):
Create new system environment variable INCLUDE and assign value %QTDIR%\include
Create new system environment variable LIB and assign value %QTDIR%\lib
Create new system environment variable QWTDIR and assign value C:\qwt-6.0.1
Create new system environment variable QMAKESPEC and assign value win32-g++
Enter the "Qt Command Prompt" via the Start menu and type:
qmake -set Q_PLUGIN_PATH C:\qwt-6.0.1\designer\plugins\designer
Here are are questions:
Am I right with my assumption, that I installed Qt and Qwt in release mode?
Does this mean, that I cannot build debug versions of my application?
I have got the debug button, so do I have a debugger which was provided with Qt-SDK (like gdb or so)?
Why does the program not stop at breakpoints?
Why does is say "process couldn't be started" when I choose debug instead of release?
What must my .pro file look like in order to debug or build a debug version? Do I have to add something like config += debug?
If I am on the wrong track, where do I have to start to get to my goal (find the bottlenecks)?
Any help would be appreciated. Please respect my background, so that I can understand you!
Thank you!