How do you find out which version of GTK+ is insta

2019-01-10 05:23发布

I need to determine which version of GTK+ is installed on Ubuntu

Man does not seem to help

10条回答
我命由我不由天
2楼-- · 2019-01-10 05:32

get GTK3 version:

dpkg -s libgtk-3-0|grep '^Version'

or just version number

dpkg -s libgtk-3-0|grep '^Version' | cut -d' ' -f2-
查看更多
女痞
3楼-- · 2019-01-10 05:35

You could also just compile the following program and run it on your machine.

#include <gtk/gtk.h>
#include <glib/gprintf.h>

int main(int argc, char *argv[])
{
    /* Initialize GTK */
    gtk_init (&argc, &argv);

    g_printf("%d.%d.%d\n", gtk_major_version, gtk_minor_version, gtk_micro_version);
    return(0);
}

compile with ( assuming above source file is named version.c):

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

When you run this you will get some output. On my old embedded device I get the following:

[root@n00E04B3730DF n2]# ./version 
2.10.4
[root@n00E04B3730DF n2]#
查看更多
Root(大扎)
4楼-- · 2019-01-10 05:36

I think a distribution-independent way is:

gtk-config --version

查看更多
forever°为你锁心
5楼-- · 2019-01-10 05:38

This will get the version of the GTK+ libraries for GTK+ 2 and GTK+ 3.

dpkg -l | egrep "libgtk(2.0-0|-3-0)"

As major versions are parallel installable, you may have both on your system, which is my case, so the above command returns this on my Ubuntu Trusty system:

ii  libgtk-3-0:amd64                                      3.10.8-0ubuntu1.6                                   amd64        GTK+ graphical user interface library
ii  libgtk2.0-0:amd64                                     2.24.23-0ubuntu1.4                                  amd64        GTK+ graphical user interface library

This means I have GTK+ 2.24.23 and 3.10.8 installed.

If what you want is the version of the development files, use pkg-config --modversion gtk+-3.0 for example for GTK+ 3. To extend that to the different major versions of GTK+, with some sed magic, this gives:

pkg-config --list-all | sed -ne 's/\(gtk+-[0-9]*.0\).*/\1/p' | xargs pkg-config --modversion
查看更多
冷血范
6楼-- · 2019-01-10 05:39

This suggestion will tell you which minor version of 2.0 is installed. Different major versions will have different package names because they can co-exist on the system (in order to support applications built with older versions).

Even for development files, which normally would only let you have one version on the system, you can have a version of gtk 1.x and a version of gtk 2.0 on the same system (the include files are in directories called gtk-1.2 or gtk-2.0).

So in short there isn't a simple answer to "what version of GTK is on the system". But...

Try something like:

dpkg -l libgtk* | grep -e '^i' | grep -e 'libgtk-*[0-9]'

to list all the libgtk packages, including -dev ones, that are on your system. dpkg -l will list all the packages that dpkg knows about, including ones that aren't currently installed, so I've used grep to list only ones that are installed (line starts with i).

Alternatively, and probably better if it's the version of the headers etc that you're interested in, use pkg-config:

pkg-config --modversion gtk+

will tell you what version of GTK 1.x development files are installed, and

pkg-config --modversion gtk+-2.0

will tell you what version of GTK 2.0. The old 1.x version also has its own gtk-config program that does the same thing. Similarly, for GTK+ 3:

pkg-config --modversion gtk+-3.0
查看更多
Deceive 欺骗
7楼-- · 2019-01-10 05:41
$ dpkg -s libgtk2.0-0|grep '^Version'
查看更多
登录 后发表回答