How to Configure Eclipse for C/C++
Par PlaceOweb le lundi, mars 14 2011, 20:34 - JAVA - Lien permanent
Based from articles How to Configure Eclipse for C/C++ and How to Install the MinGW Tools for C/C++, here an explain about configuring C/C++ under Eclipse Helios 3.6
How to Configure Eclipse 3.6 Helios for C/C++ (on Windows Seven 64bit)
Install MinGW and adding him on Windows system PATH variable
MinGW (Minimalist GNU for Windows), formerly mingw32, is a native software port of the GNU Compiler Collection (GCC)
- Install the MinGW - Minimalist GNU for Window for C/C++
- Panneau de configuration\Tous les Panneaux de configuration\Système\ > Paramètres systèmes avancés > Variable d'environnement >
- Variables systèmes
- Path => add
C:\MinGW\bin;
at end of line, for a result like%SystemRoot%\system32;%SystemRoot%;C:\MinGW\bin;
- Path => add
- Variables systèmes
- And verify MinGW install was successful. Here’s how:
- Click Start → Accessories → Command Prompt;
- In the window that appears, enter
echo %PATH%
and press the Enter key. - You should get a response including MinGW on your new path :
%SystemRoot%\system32;%SystemRoot%;C:\MinGW\bin;.;C:\Program Files (x86)\Java\jre6\bin
- In same window, enter
gcc
org++
and press the Enter key. - You should get a response
gcc: no input files
org++: no input files
. If you get any other response, then verify that you set the path correctly.
Using Eclipse ti develop and build C/C++ code
Once you have installed Eclipse, follow these directions to configure it to develop code in C/C++.
From Eclipse download page, choose current version of Eclipse IDE for C/C++ Developers. At this time, Eclipse Helios SR2 IDE for C/C++ Developers. Or use Update Sites to addon you current version of Eclipse, Help → Install New Software...
Writing Your First C/C++ Program
Create a new Eclipse workspace for your C/C++ programs
- With Eclipse shutdown, create your Eclipse workspace for C/C++ programs like
F:\workspaceEclipseCpp
(prefer to don't use space in folder name) - Launch Eclipse
- When Eclipse starts and asks you to select a workspace, click Browse and browse to the folder you created. Close the Browser and click OK in the Workspace Launcher dialog.
Create a new C or C++ project
- Go to
Window > Open perspective > Other ...
, select C/C++, and click OK. - Go to
File > New > C Project
, and choose a name for the project (for example, Greeting). - In the Project Types pane, expand Executable and select Hello World ANSI C Project
- Click Finish to accept all defaults.
Build, compile, and run the C project.
- Right-click the project (not CProjectHelloWorld.c) and select
Run As → Local C/C++ Application
. - If asked, choose the gdb Debugger.
- Look at the Console at the bottom of your screen and you will see the message the program told the computer to print.
Build, compile, and run the C++ project.
- Right-click the project (not CppProjectHelloWorld.cpp) and select
Build Project
. - Goto on you debug project folder
F:\workspaceEclipseCpp\CppProjectHelloWorld\Debug
- And run it from command line : CppProjectHelloWorld.exe
Congratulations! You have written your first program with C or C++.