I have been doing a lot of Java and Flash programming recently and both development environment have been relatively enjoyable with the Eclipse framework, so I decided to give it a try for C++. Yes I know there are other alternatives for C++ like Netbeans, Codeblocks, Codelite, and even MonoDevelop now. But having to be familiar with a single GUI is actually quite enjoyable.
- First download and install MinGW it will be your compiler. Untick everything except C compiler and C++ compiler.
- Get the latest Eclipse CDT it is the eclipse environment customized for C++.
- Launch Eclipse, open the “File” menu, then “New”, then “C++ project”
- Expand the Executable box (click on the left of it, sometimes the triangle does not show up on Windows 7). Select “Hello World C++ Project”, put a name, select “MinGW GCC”, and click Finish.
- Go to the “Project” menu and select “Build Project”.
- You should now be able to run the project and see “Hello world” in the console.
This seems all good, but actually when you try the simplest things like printf, the environment will have many issues like text not showing up. If you google for it you will find pseudo solutions recommending setvbuf( stdout, NULL, _IONBF, 0 ); but this makes things worse and create a whole lot of issues. The best is really to emulate the VS behavior and to have a separate console if you need one.
- Create gdbinit.txt in C:\MinGW\bin and put “set new-console” without the quotes in it.
- Go to the “Run” menu, then “Debugger” tab, and put “C:\MinGW\bin\gdbinit.txt” without the quotes in “GDB Command Line” and click “Apply”
Now your printf will output to the external console as they do in VS, and OutputDebugString will output text to the Eclipse console.
Overall although the printf issue is kind of bad, at the end Eclipse seem like a good environment. I like things like CTRL+SHIFT+N to automatically add a missing include file. Next time I need to write a small C++ tool, I will give it a more serious try.
Pingback: Porting a VS project to Eclipse CDT (C++) | Petit Blog