PDA

View Full Version : debug with MinGW & Qt 4.4.0



andrew209
30th May 2008, 11:45
Hi,


When I build Qt applications with the Qt makefile gdb cannot find the source files (even for my main.cpp). Exactly the same problem if I use the eclipse integration. I can successfully debug non-Qt applications with MinGW.

Any ideas welcome.

thanks
Andrew

MinGW version:
g++ (GCC) 3.4.2 (mingw-special) (and I also tried 3.4.5)
gdb version: 5.2.1 (configured as i686-pc-mingw32)
Qt version 4.4.0

lyuts
30th May 2008, 12:40
Hi,


When I build Qt applications with the Qt makefile gdb cannot find the source files (even for my main.cpp). Exactly the same problem if I use the eclipse integration. I can successfully debug non-Qt applications with MinGW.


How do you do that? Could you write all the commands you run and the output.

andrew209
30th May 2008, 17:07
I generated a new eclipse Qt App project, with just one file, main.cpp. Depending on the content of main.cpp I can debug or not debug. If I include the Qt things, then debug cannot find the source code (though the execution is correct). Details follow:

with this main:

int main(int argc, char *argv[])
{
return 0;
}

...everything is fine:

G:\eclipse\qbasic>make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `G:/eclipse/qbasic'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\Qt
\4.4.0\include\QtCore" -I"c:\Qt\4.4.0\include\QtCore" -I"c:\Qt\4.4.0\include\QtG
ui" -I"c:\Qt\4.4.0\include\QtGui" -I"c:\Qt\4.4.0\include" -I"c:\Qt\4.4.0\include
\ActiveQt" -I"debug" -I"." -I"c:\Qt\4.4.0\mkspecs\win32-g++" -o debug\main.o mai
n.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -mthreads -Wl -Wl,-subsystem,windows -o debug\qbasic.exe debug/main.o -L"c:\
Qt\4.4.0\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `G:/eclipse/qbasic'

G:\eclipse\qbasic>gdb debug\qbasic.exe
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) b main
Breakpoint 1 at 0x4012b5: file main.cpp, line 5.
(gdb) run
Starting program: G:\eclipse\qbasic/debug\qbasic.exe

Breakpoint 1, main (argc=1, argv=0x3d3dc0) at main.cpp:5
5 {
(gdb) n
12 return 0; :D perfect!
(gdb) n
13 }
(gdb) n



BUT If I change main to this:

#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QPushButton hello("Hello world @" __TIME__);
hello.show();

return a.exec();
}

make clean, and then
G:\eclipse\qbasic>make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `G:/eclipse/qbasic'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\Qt
\4.4.0\include\QtCore" -I"c:\Qt\4.4.0\include\QtCore" -I"c:\Qt\4.4.0\include\QtG
ui" -I"c:\Qt\4.4.0\include\QtGui" -I"c:\Qt\4.4.0\include" -I"c:\Qt\4.4.0\include
\ActiveQt" -I"debug" -I"." -I"c:\Qt\4.4.0\mkspecs\win32-g++" -o debug\main.o mai
n.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -mthreads -Wl -Wl,-subsystem,windows -o debug\qbasic.exe debug/main.o -L"c:\
Qt\4.4.0\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `G:/eclipse/qbasic'

Now gdb can't get a grip on the source:

G:\eclipse\qbasic>gdb debug\qbasic.exe
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) b main
Breakpoint 1 at 0x4015b0
(gdb) run
Starting program: G:\eclipse\qbasic/debug\qbasic.exe

Breakpoint 1, 0x004015b0 in main ()
Current language: auto; currently c++
(gdb) n
Single stepping until exit from function main,
which has no line number information.

:mad:
(then I just press the quit button on the window with the button in it)

Program exited normally.
(gdb) quit



Environment:

G:\eclipse\qbasic>path
PATH=c:\MinGW\bin;c:\Qt\4.4.0\bin

G:\eclipse\qbasic>set lib
Environment variable lib not defined

G:\eclipse\qbasic>set include
Environment variable include not defined

G:\eclipse\qbasic>g++ --version
g++ (GCC) 3.4.2 (mingw-special)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

G:\eclipse\qbasic>type qbasic.pro
TEMPLATE = app
TARGET = qbasic
QT += core \
gui
HEADERS +=
SOURCES += main.cpp
FORMS +=
RESOURCES +=


thanks for your time!