5

I created a simple console application in Qt. Here is source code of it:

enter image description here

When I use function Debug -> Start Debugging -> Start Debugging from the main menu, application runs and print the message "Hello world" to the console. But debugger ignores breakpoint set on line 6 (as you can see from the above screenshot).

Additional informations: QT Creator version - 2.4.1 QT library version - 4.8.1 (but there is also 4.7.4 installed in separate directory)

Project Build Settings are as follows:

enter image description here

Tool Chain settings in Tools -> Options:

enter image description here

GDB executable is present at directory "E:\QtSDK\pythongdb\python_2.7based" which is underlined by the fact that I have no problem debugging similarly GUI based Hello World program.

GDB settings:

enter image description here

Is there something I am doing wrong?

P.S. Here is my compile output:

enter image description here

Here is content of Makefile.debug:

#######################################################################

Makefile for building: PasswordGuess

Generated by qmake (2.01a) (Qt 4.8.1) on: ne 28. 4 18:12:57 2013

Project: ..\PasswordGuess\PasswordGuess.pro

Template: app

####################################################################### # Compiler, tools and options

CC = gcc
CXX = g++
DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT
CFLAGS = -g -Wall $(DEFINES)
CXXFLAGS = -g -frtti -fexceptions -mthreads -Wall $(DEFINES)
INCPATH = -I"......\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtCore" -I"......\QtSDK\Desktop\Qt\4.8.1\mingw\include" -I"......\QtSDK\Desktop\Qt\4.8.1\mingw\include\ActiveQt" -I"debug" -I"..\PasswordGuess" -I"." -I"......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\win32-g++"
LINK = g++
LFLAGS = -Wl,-subsystem,console -mthreads
LIBS = -L"e:\QtSDK\Desktop\Qt\4.8.1\mingw\lib" -lQtCored4
QMAKE = e:\qtsdk\desktop\qt\4.8.1\mingw\bin\qmake.exe
IDC = e:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\idc.exe
IDL = midl
ZIP = zip -r -9
DEF_FILE =
RES_FILE =
COPY = copy /y
SED =
COPY_FILE = $(COPY)
COPY_DIR = xcopy /s /q /y /i
DEL_FILE = del
DEL_DIR = rmdir
MOVE = move
CHK_DIR_EXISTS= if not exist
MKDIR = mkdir
INSTALL_FILE = $(COPY_FILE)
INSTALL_PROGRAM = $(COPY_FILE)
INSTALL_DIR = $(COPY_DIR)

# Output directory

OBJECTS_DIR = debug

# Files

SOURCES = ..\PasswordGuess\main.cpp
OBJECTS = debug/main.o
DIST =
QMAKE_TARGET = PasswordGuess
DESTDIR = debug\ #avoid trailing-slash linebreak
TARGET = PasswordGuess.exe
DESTDIR_TARGET = debug\PasswordGuess.exe

# Implicit rules

.SUFFIXES: .cpp .cc .cxx .c

.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<

.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<

# Build rules

first: all
all: Makefile.Debug $(DESTDIR_TARGET)

$(DESTDIR_TARGET): $(OBJECTS)
$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(OBJECTS) $(LIBS)

qmake: FORCE
@$(QMAKE) -spec ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\win32-g++ CONFIG+=declarative_debug -o Makefile.Debug ..\PasswordGuess\PasswordGuess.pro

dist:
$(ZIP) PasswordGuess.zip $(SOURCES) $(DIST) ..\PasswordGuess\PasswordGuess.pro ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\qconfig.pri ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\modules\qt_webkit_version.pri ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt_functions.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt_config.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\exclusive_builds.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\default_pre.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\default_pre.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\debug.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\debug_and_release.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\default_post.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\default_post.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\build_pass.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\console.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\declarative_debug.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\rtti.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\exceptions.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\stl.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\shared.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\warn_on.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\qt.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\win32\thread.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\moc.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\resources.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\uic.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\yacc.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\lex.prf ......\QtSDK\Desktop\Qt\4.8.1\mingw\mkspecs\features\include_source_dir.prf HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES

clean: compiler_clean
-$(DEL_FILE) debug\main.o

distclean: clean
-$(DEL_FILE) $(DESTDIR_TARGET)
-$(DEL_FILE) Makefile.Debug

check: first

mocclean: compiler_moc_header_clean compiler_moc_source_clean

mocables: compiler_moc_header_make_all compiler_moc_source_make_all

compiler_moc_header_make_all:
compiler_moc_header_clean:
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
-$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean:

# Compile

debug/main.o: ../PasswordGuess/main.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o debug\main.o ..\PasswordGuess\main.cpp

# Install

install: FORCE

uninstall: FORCE

FORCE:

Claudio
  • 10,614
  • 4
  • 31
  • 71
truthseeker
  • 1,220
  • 4
  • 25
  • 58

3 Answers3

4

Disable the flag Run in terminal under Projects->Run.

Once disabled this option, the project can be still succesfully debugged with the console output shown on the bottom panel of Qt Creator.

Claudio
  • 10,614
  • 4
  • 31
  • 71
2

SET(CMAKE_BUILD_TYPE Debug) added this line to CMakeLists.txt in case of Linux. For windows you need to set Debug keyword in .pro file.

Else you can also simply set cmake command -DCMAKE_BUILD_TYPE=Debug which is the best solution.

Refer .pro file settings

Community
  • 1
  • 1
Tushar
  • 462
  • 5
  • 12
1

It sounds like your application is built without debugging information. Make sure you're building the Debug configuration and that -g flag is used (if you're using MinGW).

Nikola Smiljanić
  • 26,745
  • 6
  • 48
  • 60