Monday, January 2, 2012

[Solved] Installing C and C++ compilers in Ubuntu

Definitely you will be in need of a compiler collection if any bit of you is a programmer. Like all Linux flavours, Ubuntu is also enables users with native C and CPP programming facility.

to install the compilers if they are not installed run the following code in Terminal.

sudo aptitude install build-essential

This will install essential compiler collection , usually gcc in your ubuntu installation. Now all you need is to create your C program and compile it. to open a file from terminal, type

vi program1.c and press enter.

you will be provided with the most popular vi editor after typing your code, type

Esc  :  wq and pres enter.

then type

gcc -o out program1.c and press enter

the output executable will be saved as, out and to execute the latter, type

./out and press enter. that's all.

you can also use gedit(GUI text editor) to type in your programs. to compile the same, cd to the directory in which the program is saved and repeat last two steps 

No comments:

Post a Comment