Solve Some Code::Blocks Problems


Update to Code::Blocks Command Locations

Newer releases of Code::Blocks may change some of the locations of key commands referenced in the book. This is more of an issue with Code::Blocks than my book, but if you send me any discrepancies I'll happily place them on the book's Errata page.

The Man Page viewer may not be found in some releases of Code::Blocks. That's okay; the version I wrote about in the book was rather unreliable when it came to displaying the man pages.

Getting a Mac Compiler

If you don't have Xcode, or Apple won't let you download Xcode because your OS X is too old, then you can obtain the clang compiler directly. Visit Download a clang release that matches your version of OS X, or the binaries for Mac OS X for an older version of clang.

In Code::Blocks you need to set clang as the compiler of choice. In Code::Blocks, choose Settings > Compiler. Choose LLVM Clang Compiler from the menu button.

Code::Blocks Won't Compile or Loses the Source Code

If you're having trouble getting Code::Blocks to compile, then you may have an issue with its installation. Specifically, Code::Blocks may be unable to find the proper directory for the compiler. Here are the steps to remedy the situation:

  1. Open a Windows Explorer window (shortcut: Win+E)
  2. Navigate to the compiler's bin folder, such as C:\Program Files (x86)\CodeBlocks\MinGW\bin
  3. Right-click in the address bar and choose the command Copy Address.
  4. Start Code::Blocks
  5. Press Ctrl+Shift+N to start a new, empty file.
  6. Choose Settings > Compiler to display the Compiler Settings dialog box.
  7. Click the tab Toolchain Executables.
  8. Paste the copied address into the Compiler's Installation Directory text box.
  9. Click the OK button to set the location.

The video (below) visually describes how to address this issue.

What is the -s Option and Why is It Obsolete?

You may see a linker warning on some Code::Blocks installations. It reads:

warning: option -s is obsolete and being ignored

I've seen this message appear primarily on Macintosh installations. Because it's a warning, the code does compile. In fact, there's nothing wrong with the code or the program; the message is just a warning because an old option was set.

Here's the man page for the ld (linker) command regarding the -s option:

-s          Completely strip the output, including removing the symbol
            table.  This file format variant is no longer supported.
            This option is obsolete.

I'm unaware of how to disable this warning, although I'm sure a switch that does the trick is hidden somewhere in Code::Blocks, where the linker options are set. When I find that location, I'll post a solution here.