Saturday, December 4, 2010

How to Install C and C++ in Ubuntu Linux

I'm extremely new in Programming field. For the first time I'm programming in C because it is in my course of study. I'm absolutely used to using Ubuntu Linux and it is my primary choice for my home operating system. For windows MSDOS there are so many C and C++ compilers originally developed and supported like Borland C, Turbo C, etc. But for Linux we have to find the alternatives. As far as I've known till now. We can use the same windows's Borland C in Linux by using 'DOSBOX'  which is little hard to get it working. But for practicing C in Linux, you can compile your C code by gcc compiler of Linux or if you are new like me you can do the following way. So, let's collect the scrambled knowledge sequentially.

1. Install C and C++ compilers in Ubuntu from the terminal by issuing the following command without quotes "sudo apt-get install build-essential"
2. After the installation completes you can start testing your C program. 
3. From the terminal window issue the command "gedit beyond.c" [beyond is the filename, you can choose your own]
3. Here's the example of my first code written in the gedit 'Text Editor' to display the texts "Hello Visitors" [you can choose your own texts]
One of the greatest program in Linux is it's test editor called 'gedit' which is very useful in programming since it automatically colors while we write a code or program.
4. If you want to try then make sure you to copy all the codes exactly, even a slightest error like (space, semicolon, etc) can make your program to get error to run. 
5. Exit the Text Editor and Now, its time to compile the code using the command "cc -c beyond.c"
6. Now, the semifinal step is to create an executable from the compiled code. To do that use the command "cc -o beyond beyond.c"
7.  Now, the final step is to run the executable file from the terminal. Use the command "./beyond" [This is the way to run executable file from terminal in Linux]. And see the output also which displays "Hello Visitors"

This is C programming.............................. Happy programming your own codes..............................

To post comments you need to have blogger or gmail ID.
You can visit more of my blogs from the below navigation bar saying 'Must visit pages' and 'Popular' menu.
or by visiting the "USE ME' tab on top.

Beyond the invisible (infinity)
"Knowing others is wisdom, knowing yourself is enlightenment."

No comments:

Post a Comment