I shifted to Ubuntu 10.10 now I am facing problem to have C/C++ compiler. What are the possible ways so that I can use C/C++ compiler using all the libraries (like graphic, math, conio, stdlib, etc) as in Microsoft Windows creating executable file?


8 Answers 8


Ubuntu provides the standard Gnu Compiler Collection in the repositories.

You can install the Gnu C Compiler gcc Install gcc as well as the Gnu C++ compiler g++ Install g++ with the following command:

sudo apt-get install gcc g++

You'll probably also want to install libc6-dev Install libc6-dev (which includes the C standard library) and libstdc++6-4.5-dev Install libstdc++6-4.5-dev (which includes the standard C++ libraries).

If you're looking for something comparable to Microsoft's Visual C++ compiler, try taking a look at Qt - specifically Qt Creator Install qtcreator. It's a full-fledged IDE with a visual form designer, code-editor, and debugger.

enter image description here

enter image description here

Now that it's clear what you mean by "perfectly as in Microsoft windows?", then Qt Creator (which I mentioned above) will be perfect for your needs. You won't need to use the console to compile your applications and the Qt framework is easy to learn and use.

There's a great tutorial for getting started with Qt here.

  • "Perfectly as in microsoft" tends to mean as i can be able to code a bit deeper using graphics and other libraries. i find it troublesome using from terminal using text editor (gedit).
    – nebula
    Mar 19, 2011 at 5:11
  • @aneal: I've edited my answer. Mar 19, 2011 at 5:17
  • thanks. i will try using that one. lets c if this is the one i am searching for .
    – nebula
    Mar 19, 2011 at 5:23

The below is (1) a simple hello-world program (2) compiled (3) made executable (4) executed. If you don't have the compiler, install gcc and g++ using the software install gui, or by running this command: sudo apt-get install gcc g++

jake@daedalus:~/playground$ cat hello.cc 
// 'Hello World!' program 

#include <iostream>

int main()
  std::cout << "Hello World!" << std::endl;
  return 0;
jake@daedalus:~/playground$ g++ hello.cc -o hello
jake@daedalus:~/playground$ chmod +x hello
jake@daedalus:~/playground$ ./hello 
Hello World!

You could install the c++ compiler via terminal.

sudo apt-get install build-essential

To write your code there a lot of editors like Gedit (installed by default) or Emacs. If you need an Integrated development environment, you could use Anjuta for example.

sudo apt-get install anjuta anjuta-extras

See: How to Compile a C/C++ Program on Ubuntu Linux

German list with IDEs

  • i wrote 'sudo apt -get install buid-essential' in the terminal. but i get a error: Sep 8, 2012 at 7:16
  • sudo : apt : command not found Sep 8, 2012 at 7:17
  • Remove the space after 'apt'.
    – BuZZ-dEE
    Sep 8, 2012 at 7:20
  • ok....someting is being installed Sep 8, 2012 at 7:26
  • To use only C++, you can only install g++ which is smaller than build-essential
    – Anwar
    Sep 8, 2012 at 7:40

GNU's gcc

It's present in all Linux/Unix distributions.


gcc hello.c

That's the compiler, but if your question is actually directed towards an IDE, then there are a couple I could recommend:



Eclipse for C/C++

...and the list goes on...


gcc(GNU Compiler Collection) is one of the most widely used C compilers. Ubuntu uses gcc and is installed by default when you install it on your system. Type gcc <filename> and g++ filename on the terminal to compile C and C++ programs respectively.


Generally, Ubuntu comes with C and C++ compiler. If you have specific requirement for some compiler then you can find and install it. If not available you can install by doing this,

sudo apt-get install build-essential

As for writing codes, there are different IDEs available. The one that I use is Eclipse IDE for C,C++ developer http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/junor. If you use IDEs then IDEs will take care of compiling program for you through their GUI but you can also build a code from command line as mentioned in detailed over here http://www.wikihow.com/Compile-a-C/C%2B%2B-Program-in-Ubuntu. Eclipse will also make your life easier when it comes to debugging your code.

Regarding your question on how to open My Computer? You will have to tell me which version of ubuntu you are using and which desktop environment?

For battery do this,

right-click on the status bar (generally on top) -> add to pannel I have added "Indicator applet complete" and then you should have battery indicator.

  • well i installed ubuntu 12.o4. its default so must be unity. thats waht i read on the internet. Sep 8, 2012 at 7:08
  • also how am i supposed to check the battery charge? Sep 8, 2012 at 7:08
  • I have updated answer for battery. Sep 8, 2012 at 7:13
  • If you find the answer helpful then I suggest to mark it as correct. Sep 8, 2012 at 7:14
  • when i right-click on the top bar nothing happens,,,no drop down menu opens up. on the extreme right there are icons for wifi BT time and settings. when i click on them specific menus for them open up but i cant see anything like "indicator applet complete" Sep 8, 2012 at 7:24

You can write your program in many ways .

If you like terminal text editors then vim and nano are there . If you like GUI text editors gedit is enough for basic users .

so i hope you know how to write a program . For example with Gedit . you can find it by typing as gedit in your unity dash which can activate by pressing Super key on your keyboard .

after opening it , type your program there and save it where you want .

Actually you should have a package named as build-essential to run your C/C++ programs succesfully . if you not installed it then you can with

sudo apt-get install build-essential

from your terminal . as you said you are a basic Ubuntu users and of course new to Ubuntu, you can get your terminal by typing as terminal in your Unity dash as i suggested above .

After saving your program to run it you have to follow these intructions to RUN it .

 g++ /path/to/file_name.cpp -o <give some name >
./<give some name >

.hope that helps.


I would suggest looking into CodeBlocks IDE. its cross platform and should be available in the Ubuntu app store.

example of its UI

Not the answer you're looking for? Browse other questions tagged or ask your own question.