c++ notes

Q: Where are the c++ library/header files located on linux ubuntu ?
A: /usr/include/

c plus plus

GTK+ library installation

I was trying to program a graphical iterface using GTK+ by following the video below.

However I didnt have the <gtk/gtk.h> library installed in my linux computer. So I tried to download it by going to gtk.org and downloading the source files but had no luck. Kept getting the same error saying
fatal error: gtk/gtk.h: No such file or directory
Then I tried to configure it but kept getting errors like
error: Package requirements (glib-2.0 >= 2.33.1 atk >= 2.5.3 pango >= 1.30.0 cairo >= 1.10.0 cairo-gobject >= 1.10.0 gdk-pixbuf-2.0 >= 2.26.0) were not met:

This was such a pain until I ran into the video below. The guy speaking you’ll not understand shit but he showed step by step

Here are the steps:
In command line:
$ sudo apt-get install libgtk2.0-dev

c++ sample code:

#include <gtk/gtk.h>
int main(int argc, char *argv[]){
    GtkWidget* window;
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    return 0;

compile the program:

$ g++ test.cpp `pkg-config --libs gtk+-2.0` `pkg-config gtk+-2.0 --cflags`

run the program:
$ ./a.out


I’ve been reading a C++ book for a couple of months now and waiting to arrive at the part where I get to build programs where I can click, drag and drop. Then I realized that the book doesn’t cover that, so I went searching for it. I found alot information on a framework called Qt by Nokia and it looks promissing. I haven’t tried it yet but it will be on my agenda to do so. If popular softwares like Autodesk Maya and VLC media players uses it, it must be good. If you used it and liked or hated it leave a comment below.

Install PySide

How to install PyQt4

C++ MVC example

I’m calling this a MVC example for simplicity. It’s actually separating 3 c++ files into 3 different responsibility for better organization and reuse-ability.

This is the header file which contain templates and functions prototype. This file will be included on the other 2 files.

#ifndef COORDIN_H_
#define COORDIN_H_

//structur templates
struct polar{
char from[50];    //distance from origin
char description[50];       //direction from origin

int balls(polar test);


This file contain functions called in file1.cpp

# include <iostream>
# include <cmath>
# include "coordin.h" //structure templates, function prototype, what links the scripts

//convert rectagular to polar coordinates
using namespace std;
int balls(polar test){
cout << test.description << endl << test.from << endl ;

This file is where you put the meat of your program. This is where you bring all the previous files together.

#include <iostream>
#include "coordin.h" // structure templates, function prototypes.  what links the scripts
using namespace std;

int main(){
polar test = {"mvc like","must compile both file1 and file2"};


return 0;

Now in order for this to work you must compile both file1.ccp and file2.cpp at the same time. Example:
$ g++ file1.cpp file2.cpp