I recently switched to Ubuntu from Windows 7. I was previously learning C++ with Microsoft's IDE, Visual Studio.

  • How would I go about programming C++ on Ubuntu, preferably with an IDE?

7 Answers 7


You have the standard gcc that comes with Ubuntu. Just ALT+F2 and type gnome-terminal or press CTRL+ALT+T to start a console.

To start programming in the console, just type nano test.c; that way you start working on your first test.c file. Try this:

#include <stdio.h>
int main ()
printf("Hello AskUbuntu!");

then just press CTRL+X and press Y, then ENTER to save and close.

Compile this test.c file using gcc by typing: gcc test.c -o mytest, which will create a file called mytest (which is executable by typing ./mytest) using the code from test.c.

The same can be said for C++ code. It works the same way as gcc: Compiling a test.cpp file using g++ by typing: g++ test.cpp -o mytest, which will create a file called mytest (which is executable by typing ./mytest) using the code from test.cpp.

This is one way.

Another way I recommend is using Code::Blocks which has been known to work since I have tested it (Ubuntu 8.04, 8.10, 9.04, 9.10, 10.04 and 10.10). Works right out the box, no errors, no nothing. The one I have used so far was Code::Blocks 8.02 but 10.05 came out a couple of months ago and it looks good.

You can install it by running sudo apt-get install codeblocks.

The last method I recommend is Aptana, which is a complete GUI IDE system. Aptana is very complex and will certainly resolve any doubt you have with its complete help system and autocomplete, autohelp way of working. Aptana is much better than the IDE from Microsoft let me tell you right now. Already worked on both for some time now and I will not leave Aptana for big works.

I will leave here some links so you can test:

APTANA - http://www.aptana.com/
CODEBLOCKS - http://www.codeblocks.org/
New Version of C - http://en.wikipedia.org/wiki/C1X
New Version of C++ - http://en.wikipedia.org/wiki/C%2B%2B0x

  • I know this is not related to the question. But the 1st part of your answer got me excited :P Do you know how to do the same thing like gcc test.c but for c++ programs ?? Thanks
    – Suhaib
    Sep 16, 2012 at 2:29
  • Oh ok the 2nd answer somehow answered my question above :)
    – Suhaib
    Sep 16, 2012 at 2:32
  • @Suhaib I "bit" too late but I added the C++ command which is g++. Works the same way. Apr 6, 2014 at 21:16
  • this is the best for c++ in linux Dec 30, 2016 at 18:24

You would start with an editor with syntax highlighting, like gedit, scite, emacs, vi or something else.

You would then learn to compile by hand, what an include-path is, what a library-path is, how to switch warnings on and off, how to build .o-files, libraries (.so), executables, and how to build makefiles.

Then you would switch to an IDE, because now you would know what to configure to what values. It's harder if you don't know what, and don't know where. I don't use C++ anymore, so I only may say that from hearsay, Code::Blocks has some good reputation.

Whether it is useful as a visual GUI-Builder I don't know - it isn't even clear from your question, whether you're looking for such a thing.

As Olcay pointed out in the comments, you need to install c++ tools (compiler, linker and so on) for c++ - maybe some dev-packages (development) too.

sudo apt-get install g++

It's not a typo, it is g++ for gnu-c++.

  • 2
    I agree with user unknown. It is the best practice to start with gedit like text editor and compiling on console. After you gain experience enough you can try Netbeans or Eclipse IDE. They are very famous and well sported IDEs. In Netbeans you have to install C++ plugin via tools->plugins section. Apr 22, 2011 at 22:49
  • 3
    Also Ubuntu doesn't come a C++ compiler preinstalled. You have to install it via synaptic package manager or by typing on console: "sudo apt-get install g++" Apr 22, 2011 at 22:59

The two most popular IDEs (If you go by reviews on the software centre) are Code::Blocks and Geany. They aren't as feature packed as Visual Studio though.

To install them you can either search on the software centre for them or stick

sudo apt-get install geany

enter image description here

sudo apt-get install codeblocks

enter image description here

in the terminal.


Depending on what you want to do, you might want to use:

  • For general-purpose, non-GUI-related C++ development, you can use Eclipse and the CDT plugin

enter image description here

  • If you want to write a C++ application with a GUI, you can use Qt Creator

enter image description here


I recommend you to use QtCreator or NetBeans - you should try them and you will see that these 2 IDE's are the best for C++ development.
Geany, Aptana(which is actually intended for Web Development) and Codeblocks are not good when you try them all, I assure you.
P.S: Don't listen to guys that tell you that you are not a good programmer if you write programms in IDE's, that's just plain stupid and childish(when they grow up they won't think like this any more). The IDE's don't write the code for you...
To add, even some Linux Kernel developers switched to Qt Creator. Valve and a lot of other big names in the industry use Qt Creator for C and/or C++ development on Linux.


You may try the Ubuntu SDK.

Install it by typing this in terminal:

sudo apt-get install ubuntu-sdk

From the Create Project window choose Non-Qt and Plain C++.


IDEs are pretty much a necessity with C++ because of their code completion and project management features. If however you want to stick with vim, the "YouCompleteMe" plugin is very effective and uses clang for it's backend. It also can be configured using an unobtrusive dot config file that you can check-in to your source tree and YCM will do the right thing when you're in that tree.

Now if I could only get YCM working with the Linux kernel sources.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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