C++ debugging in Eclipse IDE

If you’re a Java developer and find yourself also doing some coding in another language, you don’t want to have to change your IDE just to do so. That would make the learning curve twice as steep. Fortunately, if you use the Eclipse IDE and you need to code in C++ (or JavaScript), you don’t have to switch.

CHUA Hock-Chuan has an excellent guide about how to set this up. Some caveats:

  1. I tested with MinimalGnuWindows; I don’t know if I’m missing out on something better in Cygwin (but everytime I’ve encountered Cygwin’s installer, I wonder why it’s so difficult to use)
  2. To get support for the 2011 version of C++¬†(aka “C++0x” or “C++11”), go to Project | Properties | C/C++ Build | Settings | GCC C++ Compiler | Miscellaneous | Other flags and append -std=c++11 to whatever might already be there. Then do the same for GCC C Compiler | Miscellaneous | Other flags.
  3. “Clean”ing a project may not work on your Windows (ref1) (ref2), because it uses “rm -rf”. If this happens, install GNU CoreUtils, make sure it’s in your PATH (i.e., append ;C:\Program Files (x86)\GnuWin32\bin), and restart Eclipse.
  4. When you get to the point of entering the C++ helloworld, std, cout, and endl will show errors about not being able to resolve them. These errors disappeared when I saved the file, which probably means there’s a fast kind of syntax-checking done for (almost) every key press, and a more expensive compilation done only when edits are saved.
  5. If you check the Includes settings under Project, all the paths will be entirely down-cased. My actual paths use some camel-casing and work fine, so this must just be a quirk of the dialog.
  6. Even if the project is set to Build Automatically, you must still select Project | Build Project for the binaries to be created.
    1. If ‘clean’ or ‘build project’ fail with error ‘make cannot be found in PATH’, then ensure you have the following setting: Project | Properties | C/C++ Build | Tool Chain Editor | Current toolchain = MinGW GCC. If you had to change this setting, try cleaning or building again.
Print Friendly, PDF & Email