Browse Articles in Linux How To
Andre Honsberg Andre Honsberg is a software engineer who develops mostly for the Web. He lives in Hamburg Germany and works building software for the web using a wide spectrum of different technologies.

In Ubuntu we can use apt-get to install the build essential package available in the repository to get our GCC c/c++ compiler working. This will also help with being able to install programs from source.

Now open up a terminal. You can do this easily by holding down [ALT] and pressing [F2] which brings up the "Run Application" window. Then type gnome-terminal and press [Enter]. Now at the terminal we will first update, upgrade and then install the build=essential package.

# update apt-get resources
$ sudo apt-get update

# update the system
$ sudo apt-get upgrade

# install build-essentials
$ sudo apt-get install build-essential

# check the versions to see if everything is correct
$ gcc -v
$ make -v

Now you can compile c/c++ programs easily on the command line. If you had a c file called calendar.c you can now compile it using the following command.

# compile calendar.c
$ gcc calendar.c -o calendar

# run compiled calendar program
$ ./calendar
Want to leave a Commnet?
Wednesday the 24th of July, 2013 at 19:30:34
Gravatr Image
So how do I compile c++ programs with gcc? I have gcc installed and it doesn't seem to be able to do that.
Andre Honsberg
Wednesday the 24th of July, 2013 at 19:32:23
Gravatr Image
use g++ myprog.cpp