I've been programming for about a year and a half on Windows and I've just started getting used to the way things work on that platform, but now I'm interested in development on Linux and I've been having a tough time getting used to the workflow, lack of IDE, and command line compilation with GCC. I'm running Xubuntu 13.10 64bit, by the way..

To test the waters, I did what many people do and wrote a quick C++ 'hello world' program.

#include <iostream>

int main()
    std::cout << "Hello!\n";
    return 0;

My first issue is; this program seems to get a compilation error when I try to compile it using GCC, but it compiles fine when I use the G++ compiler:

gcc hello.cpp -o hello
/tmp/ccbmUmzf.o: In function `main':
hello.cpp:(.text+0xa): undefined reference to `std::cout'
hello.cpp:(.text+0xf): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccbmUmzf.o: In function `__static_initialization_and_destruction_0(int, int)':
hello.cpp:(.text+0x3d): undefined reference to `std::ios_base::Init::Init()'
hello.cpp:(.text+0x4c): undefined reference to `std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status

What's going on here, is GCC failing to recognize that my code is C++ or something?

My second issue is with trying to use libraries: I was under the impression that the GTK+3.0 development libraries come included with (X)ubuntu, but when I try to follow the simple tutorial here, i get the following error from G++:

g++ hello.cpp -o hello
hello.cpp:1:21: fatal error: gtk/gtk.h: No such file or directory
 #include <gtk/gtk.h>
compilation terminated.

So then, I interpreted that to mean that the libraries for GTK+3.0 aren't installed.. So I checked apt-get, and I didn't really see anything that looked like what I needed.. Do i have to build GTK+3.0 from source, or is there some PPA somewhere that I need??

These issues are really frustrating to me.. I know that a lot of people swear by the GNU/Linux development workflow, but as someone who is used to working in Visual Studio, I'm finding the process to be somewhat opaque and unintuitive. Right now I'm using Mousepad on Xubuntu to edit my code, and while it has color-coded syntax, it seems to do very little beyond that. I know that eventually I'll have to deal with multiple files and creating makefiles and, at this point, I'm dreading it!

Whatever help you can give to a novice programmer and total Linux/GNU noob is very welcome!

1 Answer 1



First of all, you don't have to settle for no IDE. Install Eclipse, it's available in the Ubuntu Software Centre. You also want to install CDT for Eclipse which gives you C/C++ support. Second I'd very much advise you to focus on C++ and Qt instead of C and GTK. Qt is a great cross-platform framework that uses C++ and QML (a JavaScript-like language for UI), and Ubuntu is moving more and more towards using Qt for their future desktop and mobile development. These tools will allow you not only to create beautiful applications for Ubuntu desktop but also for Android, Windows, Mac, BlackBerry and other OSes. An excellent Qt-specific IDE is QtCreator, also available in the Ubuntu Software Center, you should check it out along some Qt tutorials.


To answer you question directly, even though I strongly recommend doing what I outlined above, you likely need the -dev versions of the libraries you use. For GTK 3, you likely have to:

sudo apt-get install libgtk-3-dev

That should get you all GTK 3 headers.

  • I'll admit, I'm aware of Qt, and I made the decision to try out GTK+ somewhat arbitrarily! My reasoning was, as an Xubuntu user, I thought GTK might have already been installed due to it being a dependency of XFCE (unless I'm mistaken). Also, while GTK is a C library, doesn't it also work with C++ programs? I don't want this to become a GTK vs Qt war, I'm sure both are great, but at this point I'm just trying to pick one and get it working! - Also, the Eclipse suggestion is something to consider, for sure.. :] Dec 6, 2013 at 5:14
  • 1
    Look at my edit. GTK is a dependency, but for apps to work, only the binary part is needed. What you need to compile is the headers, which come in a separate package - usually the library name with -dev at the end. I had the feeling you made the choice rather arbitrarily from your question, which is why I allowed myself to give you some direction. You can use GTK with C++ but you have to use another library unless you want to deal with a lot of ugly C within C++. I think its GTKmm. That said, Qt is a lot more portable, is written in C++ and has a great language for UIs. Dec 6, 2013 at 5:20
  • 1
    I'd say - try some simple UI stuff in both and make up your mind, evaluating the potential code reuse you can do across platforms with either. Definitely try QtCreator. Dec 6, 2013 at 5:21
  • Installing libgtk-3-dev worked like a charm, thanks! Of course it would be as simple as that; the run time libraries were there but not the headers, I see. Still finding it hard to find what I need (and what I already have installed) using APT, but that's a question for another time.. I've read a lot of great things about Qt, and I will definitely give it a try also! Thanks for the simple, effective answer AND the honest advice/opinion, lightrush! Dec 6, 2013 at 5:23
  • Also, you wouldn't happen to have any idea why I had that issue with GCC vs G++ at the top of my question, would you? I'm guessing it has something to do with the C++ standard library not being included correctly when run through GCC, but i'm not sure.. Any ideas? Dec 6, 2013 at 5:28

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.