I guess you were trying to debug a standalone file (file not belonging to a project). Code::Blocks doesn't support debugging such files. Try including the file to be compiled as a part of an empty project or something.
How to debug standalone file in Code::Blocks?
-
14-07-2023 - |
Вопрос
I'm programming using Code::Blocks. I set some breakpoints, but Code::Blocks seems to ignore them when I run the program.
By 'start the program' I mean simply clicking (Build and run).
I checked under Debug
and saw that F8
isn't available (Start / Continue):
The program compiles and runs fine, it just ignores breakpoints. Does anybody know how to solve this?
Note: I checked here and I think the suggested answer isn't relevant for me, because in Compiler settings
I have just "C:\MinGW" under Compiler's installation directory
.
edit:
I'm using Windows 8 (64bit), Code::Blocks 12.11
Решение
Другие советы
In Code::Blocks, go into your Settings
menu, then click Compiler
. Make sure Global compiler settings
is selected in the sidebar, then switch to the Toolchain executables
tab. Your Debugger
entry should say something like GDB/CDB debugger: default. If it does, OK out of this dialog.
Go back into the Settings
menu and select Debugger
. In the GDB/CDB debugger
tree on the left, select Default
. Make sure the Executable path
textbox is set to your gdb.exe - in your case, the correct path will probably be something like C:\MinGW\bin\gdb.exe. Make sure the Debugger Type
is set to GDB. Then hit OK
.
Now your debugger (GDB) should be set up. Restart Code::Blocks if you like (I've had it glitch out before, crash, and lose whatever settings I changed since last restart), then go into the Debug
menu and Start/Continue
should be enabled.
remember about this: http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks#Path_with_spaces
Breakpoints could not work if the path/folder you've placed your project contains spaces or other special characters. To be safe use English letters, digits and '_'.
Check out the following things:
- You do not have spaces included in your project path directory.
- You do not have spaces included in any of the project files.(eg. .cbp file, .c file)
- If you are running codeblock on ubuntu then make sure you are running it as superuser.(eg. >gksu codeblocks)
Instead of space, you can use underscore(_) character.
For my sitiuation, there were 2 difference gdp path to be selected in Settings -> Debugger. Exe was stopped when i debug in secound path was selected. So, i changed my debugger path to correct path where is codeblocks is installed.(first path).
It works :)
- C:\Program Files (x86)\CodeBlocks\MinGW\gdb32\bin
- C:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0\mingw64\bin
The best way to handle the problem is if you put the code on a project then the debugging tool will be available then
I was facing the same problem. What worked for me is that after you have selected gdb in settings compiler and debugger menu, JUST CREATE A NEW PROJECT DO NOT CONTINUE WORKING ON THE CURRENT PROJECT debugging menu will be enabled.