Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
I've download GTK+ 3.8, GLib 2.36, Pango 1.34, Gdk-Pixbuf 2.28, ATK 2.8 from http://www.gtk.org/download/linux.php[^]
When I tried to instal each package above, it told that my computer misses other packages. For example, when I install ATK, it told that my computer misses Cairo graphic. And lots, lots are missing. It makes me crazy. Does anyone tell me the easiest way I can install GTK+ ?
Posted

If you just want to use the recent gtk production build, you should use apt-get to install. Unless you are doing some gtk development or something equally esoteric, you should not download and install the way you did here.

What you want to do is:

XML
sudo apt-get install libgtk-3-dev


which will determine all the dependencies and install everything in the correct order and hierarchy.
 
Share this answer
 
Firstly try download archive with the version necessary to you from here:
http://www.gtk.org/download/linux.php
We unpack downloaded archive: "tar -xzvf gtk+-2.20.1.tar.gz"
We go to the unpacked folder: "cd gtk +-2.20.1"
We check a source in our system: "./configure"
If gives out that somethings don't suffice, we put a package: ibgtk2.0-dev: sudo apt-get install libgtk2.0-dev
We try again ". / configure" command
If again it inform that didn't find the necessary packages then try put them manually...
For example, if exist the following message : "No package 'glib-2.0' found No package 'atk' found No package 'pango' found No package 'cairo' found No package 'cairo-gobject' found No package 'gdk-pixbuf-2.0' found"
For example we need a glib-2.0 then we write: sudo apt-get install libglib2.0-dev (real estate development package, that is the development package), if that is necessary a dev package will pull for itself and other necessary packages.
Further, when ". / configure" doesn't swear any more, we write: " make"
After the "make" command, please write: "sudo make install"
Also,". / configure" can issue the following:
"configure: error:
*** Checks for TIFF loader failed. You can build without it by passing
*** --without-libtiff to configure but some programs using GTK+ may
*** not work properly"
Then you need to run "configure" with parameter: "./configure --without-libtiff"

Now we are trying to compile small simple example:
C++
//===================================
#include <gtk/gtk.h>

void
hello (void)
{
  g_print ("Hello World\n");
}

void
destroy (void)
{
  gtk_main_quit ();
}

int
main (int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *button;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_signal_connect (GTK_OBJECT (window), "destroy",
              GTK_SIGNAL_FUNC (destroy), NULL);
  gtk_container_border_width (GTK_CONTAINER (window), 50);

  button = gtk_button_new_with_label ("Hello World");

  gtk_signal_connect (GTK_OBJECT (button), "clicked",
              GTK_SIGNAL_FUNC (hello), NULL);
  gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
                 GTK_SIGNAL_FUNC (gtk_widget_destroy),
                 GTK_OBJECT (window));
  gtk_container_add (GTK_CONTAINER (window), button);
  gtk_widget_show (button);

  gtk_widget_show (window);

  gtk_main ();

  return 0;
}
//===================================

Compile as follows:
gcc -o gtk_program `pkg-config --cflags --libs gtk+-2.0` gtk.c

Good luck.
Alex.
 
Share this answer
 
Comments
Nguyen Hung Duong 12-Aug-13 12:32pm    
Thanks so much
Volynsky Alex 12-Aug-13 16:31pm    
You are welcome Nguyen Hung Duong :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900