Aller au contenu | Aller au menu | Aller à la recherche


How to Configure Eclipse for C/C++

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)

  1. Install the MinGW - Minimalist GNU for Window for C/C++
  2. Panneau de configuration\Tous les Panneaux de configuration\Système\ > Paramètres systèmes avancés > Variable d'environnement >
    1. Variables systèmes
      1. Path => add C:\MinGW\bin; at end of line, for a result like %SystemRoot%\system32;%SystemRoot%;C:\MinGW\bin;
  3. And verify MinGW install was successful. Here’s how:
    1. Click Start → Accessories → Command Prompt;
    2. In the window that appears, enter echo %PATH% and press the Enter key.
    3. You should get a response including MinGW on your new path : %SystemRoot%\system32;%SystemRoot%;C:\MinGW\bin;.;C:\Program Files (x86)\Java\jre6\bin
    4. In same window, enter gcc or g++ and press the Enter key.
    5. You should get a response gcc: no input files or g++: 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
  1. With Eclipse shutdown, create your Eclipse workspace for C/C++ programs like F:\workspaceEclipseCpp (prefer to don't use space in folder name)
  2. Launch Eclipse
  3. 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
  1. Go to Window > Open perspective > Other ..., select C/C++, and click OK.
  2. Go to File > New > C Project, and choose a name for the project (for example, Greeting).
  3. In the Project Types pane, expand Executable and select Hello World ANSI C Project
  4. Click Finish to accept all defaults.
Build, compile, and run the C project.
  1. Right-click the project (not CProjectHelloWorld.c) and select Run As → Local C/C++ Application.
  2. If asked, choose the gdb Debugger.
  3. 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.
  1. Right-click the project (not CppProjectHelloWorld.cpp) and select Build Project.
  2. Goto on you debug project folder F:\workspaceEclipseCpp\CppProjectHelloWorld\Debug
  3. And run it from command line : CppProjectHelloWorld.exe

Congratulations! You have written your first program with C or C++.

Ajouter un commentaire

Le code HTML est affiché comme du texte et les adresses web sont automatiquement transformées.

Fil des commentaires de ce billet