Monday, May 30, 2016

how to install gtkmm on ubuntu 16.04 in 3 steps

To Install gtkmm on ubuntu 16.04 / 14.04 follow the 3 steps bellow.
  •  step 1 : install the updates 

sudo apt-get update 
  • step 2 :   Install the Gnu c++ compiler "g++" if is not installed (you will need it to compile your code ).

 sudo apt-get install g++


  • step 3 : Install gtkmm  

 sudo apt-get install libgtkmm-3.0-dev 


Now after doing this 3 steps the installation is done you need now to create a simple application example and compile it to check if every thing is working .
you can copy past the example bellow to chack if your environment is ready to start programing with gtkmm 
  • first step you need to create a c++ file like the example.
in our example the file name is GtkmmTutorial.cpp

 #include <gtkmm.h>

int main(int argc, char *argv[])
{
 
  Gtk::Main kit(argc, argv);
  Gtk::Window GtkmmTutorial;
  GtkmmTutorial.set_default_size(400, 400);
  Gtk::Main::run(GtkmmTutorial);

  return 0;
}

  • second step compile your code you can replace "GtkmmTutorial.cpp" by your file name and the output file "GtkmmTutorial" by any name you want.
g++ GtkmmTutorial.cpp -o GtkmmTutorial `pkg-config gtkmm-3.0 --cflags --libs`

  • last step after compiling your code  you will see a new executable file, just double click on it and you will see an empty window. 

if you don't  have any problem with this steps, you are now ready to start programing with gtkmm, but if you have any problem with installation jut leave comment with your problem details i will reply you with the solution.




4 comments:

  1. I get this, any help

    The following packages have unmet dependencies:
    libgtkmm-3.0-dev : Depends: libgtk-3-dev (>= 3.18.0) but it is not going to be installed
    Depends: libglibmm-2.4-dev (>= 2.46.1) but it is not going to be installed
    Depends: libcairomm-1.0-dev (>= 1.12.0) but it is not going to be installed
    Depends: libpangomm-1.4-dev (>= 2.38.1) but it is not going to be installed
    Depends: libatkmm-1.6-dev (>= 2.24.1) but it is not going to be installed
    Depends: libgdk-pixbuf2.0-dev (>= 2.26.0) but it is not going to be installed

    ReplyDelete
  2. I am attempting to run the "HelloWorld in gtkmm" example in the gnome.org/gtkmm-tutorial, but I get errors - helloworld.cc:(.text+0x2d9): undefined reference to `VTT for HelloWorld'
    helloworld.cc:(.text+0x2f5): undefined reference to `vtable for HelloWorld' Can you help, please

    ReplyDelete
  3. after all those 3 steps i am getting > only and nothing else
    thanks

    ReplyDelete