Thursday, July 15, 2010

Installing CDT( C/C++ Development Tool ) in Eclipse and Running C/C++ program

Hi, I could write this blog only after visiting many sites, Thanks for those websites.
As you all know Eclipse a famous IDE compiler for Java. Here why I'm choosing Eclipse (Galileo) instead of other IDE compiler because Eclipse is used vastly and stable one, in eclipse you can easily trace out the flow of control of Java code and also you can easily understand the program.

Do you also know, we can install other compilers in eclipse as a plug-ins? Yes, we can install as plug-in. "Thanks for the Development Team". Here I'm blogging how we can install it but before that we need to install Eclipse IDE Compiler and we can install it by command

sudo apt-get install eclipse

Installing CDT

1. Run the Eclipse and in Main menu go-to Help->Install New Softwares. It will open a window with option "Work with" .
2. In "Work with" field paste the below link
CDT - http://download.eclipse.org/tools/cdt/releases/galileo

3. It will show the below two options,
+ CDT Main Features &
+ CDT Optional Features

check these two and also the four options in the "Details" field and Click "Next". (The downloading size of package is 100-120 MB)

4. Once it is finished then your are ready to run the C/C++ program.


Running C/C++ program in Eclipse

Running C/C++ program in eclipse is not easy, its a bit longer process than installing CDT :-)
For Windows Click here.
For Linux follow the below steps. And before that write the code in simple file with the extension C. Ex:- HelloWorld.C or first.c

Step 1: Open C/C++ perspective
1. Run the Eclipse and go-to "Windows-> Open Perspective-> Others

2. In "Open Perspective" window select C/C++ and click OK


Step 2: Create a C/C++ project
1. In Main menu "File->New->C Project"


2. In "C Project" window mention the "Project Name", select the "Project Type" and Select proper "Tool Chains" as show in below fig. Then click "Next".
3. Next it shows the two options of "Debug & Releases", select both and click "Finish".

Step 3: Adding files to the C Project.
1. Right click on Project name->New->Source File
2. Mention the "Source File" name with extension "C".
3. Again right click on Project name and Import files.
(REMEMBER) Where Importing file should contain C code.

4. In Import Source File, "General-> File System" and click Next.
5. Now browse the file in which your C code of Hello World.
6. Now select the file in which your "Hello World" C code should be there.
7. Now it will open that file. As shown below

Step 4: Build and Run the project manually
1. In Main menu go-to "Project-> Build Project"
2. Now Run the program as shown below or press "Ctrl+F11"
3. Observe the output in "Console" window.


Comments are welcomed.

2 comments:

karthik bhat said...

Good effort..

what about windows?

Ajay Kulkarni said...

Thank you..
see in "Running C/C++ prog" section, on the 3rd line u get