如何在ubuntu中安装GTK + [英] How can I install GTK+ in ubuntu

查看:670
本文介绍了如何在ubuntu中安装GTK +的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 http://下载GTK + 3.8,GLib 2.36,Pango 1.34,Gdk-Pixbuf 2.28,ATK 2.8 www.gtk.org/download/linux.php [ ^ ]

当我尝试安装上面的每个包时,它告诉我的计算机错过了其他包。例如,当我安装ATK时,它告诉我的电脑错过了开罗图形。很多,很多都没有了。这让我很疯狂。有没有人告诉我安装GTK +最简单的方法?

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+ ?

推荐答案

如果你只想使用最近的gtk生成版本,你应该使用apt-get来安装。除非你正在做一些gtk开发或同样深奥的东西,否则你不应该按照你在这里的方式下载和安装。



你想要做的是:



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:

sudo apt-get install libgtk-3-dev





将确定所有依赖项并按正确的顺序和层次安装所有内容。



which will determine all the dependencies and install everything in the correct order and hierarchy.


首先尝试从此处下载所需版本的存档:

http://www.gtk.org/download/linux.php

我们解压缩下载的档案:tar -xzvf gtk + -2.20.1.tar.gz

我们去解压后的文件夹:cd gtk + -2.20.1

我们检查系统中的源:./ configure

如果发现某些东西不够,我们放一个包:ibgtk2.0-dev:sudo apt-get install libgtk2 .0-dev

我们再试一次./configure命令

如果再次通知没找到必要的包然后尝试手动放置它们...

例如,如果存在以下消息:没有包'glib-2.0'发现没有包'atk'发现没有包'pango'发现没有包'cairo'发现没有包'cairo-gobject'发现没有包'gdk-pixbuf-2.0'发现

例如我们需要一个glib-2.0然后我们写:sudo apt-get install libglib2。 0-dev(房地产开发包,即开发包),如果有必要,dev包将为自己和其他必要的包拉。

此外,当。 / configure不再发誓了,我们写道:make

在make命令之后,请写下:sudo make install

此外, 。 / configure可以发出以下内容:

configure:错误:

***检查TIFF加载程序失败。您可以通过传递

*** --without-libtiff进行配置,但是使用GTK +的一些程序可能

***无法正常工作

然后你需要用参数运行configure:。/ configure --without-libtiff



现在我们正在尝试编译一个简单的小例子:

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:
//===================================
#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;
}
//===================================



编译如下:

gcc -o gtk_program`pkg-config --cflags --libs gtk + -2.0` gtk.c



祝你好运。 />
Alex。


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

Good luck.
Alex.


这篇关于如何在ubuntu中安装GTK +的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆