Skip to content


Missing debugging symbols in Code::Blocks

This post in a nutshell: check that global compiler settings aren’t configured with flags like -s. The global settings tend to override any other settings.

I recently started (finally found the time) to really do stuff in C++. My IDE of choice was Code::Blocks, because:

  1. It’s available on both Windows and Linux so hopefully when I’ll try to I won’t have trouble compiling on Linux with very few tweaks to get the thing working
  2. It’s light, free (as in FLOSS), written in C++, using wxWidgets… So on the whole, very clean and FLOSS-ish 🙂
  3. I tried Eclipse but for some reason it was quite crash-prone. I traced the issue to be somewhat related to auto-completion and such, but anyway, Eclipse isn’t exactly what I’d call “light”, even though it would have been “light enough” for me, I guess (I do use it for PHP sometimes)

As for the compler I picked TDM-GCC, which seems to be the place where current versions of GCC for Windows are to be found. The reason for this choice was because it’s free and available both on Windows and Linux, and easy to install and use (particularly on Linux, but on Windows too).

Anyway, after a reasonably short while I reached the classical point where I have to debug. And by this I mean “debug”, not just recompile with some std::cout all around the place ;). And here is where things got complicated: although I was running in debug mode, the debugger didn’t stop at breakpoints. The project’s “Debug” target (Project->Build options) was properly configured, though:

  • Produce debugging symbols [-g] was checked
  • Strip all symbols [-s] was NOT checked
  • Even though that’s not mandatory (but useful to see most variables), optimizations were disabled
  • Finally, I had also added manually the -ggdb flag

Strangely enough, even though, as above-mentioned, the “Debug” target was properly configured, the debugger was complaining about missing debugging symbols:

Build succeeded
Selecting target: 
Debug
Adding source dir: C:\[...]\MyFolder\
Adding file: bin\Debug\MyExe.exe
Starting debugger: 
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Reading symbols from C:\[...]\MyFolder/bin/Debug/MyExe.exe...(no debugging symbols found)...done.
Debugger name and version: GNU gdb (GDB) 7.2
Child process PID: 2110
Program exited normally.
Debugger finished with status 0

After *a lot* of searching around, I eventually though of checking the global compiler settings (Settings->Compiler and debugger->Global compiler settings). And the -s flag was enabled there! (and somehow it seems that global compiler settings are combined with per project settings, ie when a flag is globally enabled it’s silently enabled in all project).

So, the “fix” was simple: disable the -s flag in the global compiler settings. To avoid further issues, I actually think it’s best to stay away from those global compiler settings. The only flag I left enabled there is the “Enable all compiler warnings” flag [-Wall], I really care about programming with no warning, as a warning is always a potential future issue in my opinion.

Posted in programming.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA