转:Configure your eclipse for C++
from: http://omtlab.com/configure-your-eclipse-for-c/
Configure your eclipse for C++
This is small sample of how to use eclipse for c++.
There are two ways to use eclipse for C++.
1) Download Eclipse CDT : It is separate eclipse only for C/C++.
2) Download C++ Plugin in you existing eclipse.
I recommend you to download separate Eclipse CDT.
Download from here : http://www.eclipse.org/cdt/
After downloading eclipse CDT you need to download C++ compiler.
I am using MinGW compiler with eclipse. There are some other compiler like : cygwin
You need to install MinGW compiler in your pc.
Download MinGW from here : http://www.mingw.org/
After installing MinGW you need to set environment variable (MINGW_HOME) in you pc.
Name of variable is MINGW_HOME and set MinGW install directory as a path (Example : C:\MinGW).
All are set and now you can open your eclipse CDT.
Create new C++ project.
Goto File > New > C++ Project.
Small popup will open. Enter below details in it.
1) Enter your project name.
2) Select Project Type : Hello World C++ Project.
3) Select Toolchains: MinGW GCC.
Click on Next,Next and Finish.
Now final step before build your hello world project.
Right Click on your project and click on Properties.
Goto Project > Properties > C/C++ Build > Settings > Tool Settings (Tab) > MinGW C++ Linker (Option) > Add Command (g++ -static-libgcc -static-libstdc++) (default command is only g++)
Right click on your project select Build Project option.
It will generate some output in console.
23:43:15 **** Rebuild of configuration Debug for project omtcppexample ****
Info: Internal Builder is used for build
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o “src\\omtcppexample.o” “..\\src\\omtcppexample.cpp”
g++ -static-libgcc -static-libstdc++ -o omtcppexample.exe “src\\omtcppexample.o”23:43:17 Build Finished (took 1s.596ms)
Again Right Click on your project and Run as > Local C/C++ Application.
Output :
!!!Hello World!!!