I need to determine which version of GTK+ is installed on Ubuntu
我需要确定在Ubuntu上安装了哪个版本的GTK+。
Man does not seem to help
人类似乎帮不了什么忙
10 个解决方案
#1
57
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).
这个建议将告诉您已经安装了2.0版本。不同的主要版本将有不同的包名,因为它们可以在系统上共存(以便支持使用旧版本构建的应用程序)。
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).
即使对于开发文件(通常只允许在系统上使用一个版本),也可以使用gtk 1的版本。x和同一系统上的gtk 2.0版本(包含的文件位于名为gtk-1.2或gtk-2.0的目录中)。
So in short there isn't a simple answer to "what version of GTK is on the system". But...
因此,简而言之,对于“系统上的GTK是什么版本”,没有一个简单的答案。但是…
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).
要列出系统上的所有libgtk包,包括-dev包。dpkg -l将列出dpkg知道的所有包,包括当前未安装的包,因此我使用grep只列出已安装的包(以I开头)。
Alternatively, and probably better if it's the version of the headers etc that you're interested in, use pkg-config:
或者,如果是你感兴趣的头文件版本,可以使用pkg-config:
pkg-config --modversion gtk+
will tell you what version of GTK 1.x development files are installed, and
将告诉您GTK 1的哪个版本。安装了x开发文件
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:
将告诉您GTK 2.0的哪个版本。旧1。x版本也有自己的gtk-config程序,它也做同样的事情。同样,为GTK + 3:
pkg-config --modversion gtk+-3.0
#2
23
$ dpkg -s libgtk2.0-0|grep '^Version'
#3
21
get GTK3 version:
得到GTK3版本:
dpkg -s libgtk-3-0|grep '^Version'
or just version number
或者只是版本号
dpkg -s libgtk-3-0|grep '^Version' | cut -d' ' -f2-
#4
7
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):
编译(假设上面的源文件被命名为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]#
#5
4
Try,
试,
apt-cache policy libgtk2.0-0 libgtk-3-0
or,
或者,
dpkg -l libgtk2.0-0 libgtk-3-0
#6
3
You can also just open synaptic and search for libgtk, it will show you exactly which lib is installed.
您还可以打开synaptic并搜索libgtk,它将显示安装了哪个库。
#7
2
Try:
试一试:
dpkg-query -W libgtk-3-bin
#8
1
I think a distribution-independent way is:
我认为一种独立于分配的方式是:
gtk-config --version
gtk-config——版本
#9
1
This will get the version of the GTK+ libraries for GTK+ 2 and GTK+ 3.
这将获得GTK+ 2和GTK+ 3的GTK+库的版本。
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:
由于主要版本是可并行安装的,所以您的系统上可能有这两个版本,这是我的情况,所以上面的命令在我的Ubuntu可靠系统上返回:
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.
这意味着我已经安装了GTK+ 2.24.23和3.10.8。
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——例如gtk+-3.0的modversion gtk+-3.0来实现gtk+ 3。要将其扩展到GTK+的不同主要版本(使用一些sed魔法),以下给出:
pkg-config --list-all | sed -ne 's/\(gtk+-[0-9]*.0\).*/\1/p' | xargs pkg-config --modversion
#10
0
To make the answer more general than Ubuntu (I have Redhat):
为了让答案比Ubuntu更通用(我有Redhat):
gtk is usually installed under /usr, but possibly in other locations. This should be visible in environment variables. Check with
gtk通常安装在/usr下,但也可能安装在其他位置。这在环境变量中应该是可见的。检查一下
env | grep gtk
Then try to find where your gtk files are stored. For example, use locate
and grep.
然后尝试找到您的gtk文件存储的位置。例如,使用locate和grep。
locate gtk | grep /usr/lib
In this way, I found /usr/lib64/gtk-2.0
, which contains the subdirectory 2.10.0
, which contains many .so library files. My conclusion is that I have gtk+ version 2.10. This is rather consistent with the rpm command on Redhat: rpm -qa | grep gtk2
, so I think my conclusion is right.
这样,我找到了/usr/lib64/gtk-2.0,它包含子目录2.10.0,其中包含许多.so库文件。我的结论是,我有gtk+ 2.10版本。这与Redhat的rpm命令是相当一致的:rpm -qa | grep gtk2,所以我认为我的结论是正确的。
#1
57
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).
这个建议将告诉您已经安装了2.0版本。不同的主要版本将有不同的包名,因为它们可以在系统上共存(以便支持使用旧版本构建的应用程序)。
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).
即使对于开发文件(通常只允许在系统上使用一个版本),也可以使用gtk 1的版本。x和同一系统上的gtk 2.0版本(包含的文件位于名为gtk-1.2或gtk-2.0的目录中)。
So in short there isn't a simple answer to "what version of GTK is on the system". But...
因此,简而言之,对于“系统上的GTK是什么版本”,没有一个简单的答案。但是…
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).
要列出系统上的所有libgtk包,包括-dev包。dpkg -l将列出dpkg知道的所有包,包括当前未安装的包,因此我使用grep只列出已安装的包(以I开头)。
Alternatively, and probably better if it's the version of the headers etc that you're interested in, use pkg-config:
或者,如果是你感兴趣的头文件版本,可以使用pkg-config:
pkg-config --modversion gtk+
will tell you what version of GTK 1.x development files are installed, and
将告诉您GTK 1的哪个版本。安装了x开发文件
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:
将告诉您GTK 2.0的哪个版本。旧1。x版本也有自己的gtk-config程序,它也做同样的事情。同样,为GTK + 3:
pkg-config --modversion gtk+-3.0
#2
23
$ dpkg -s libgtk2.0-0|grep '^Version'
#3
21
get GTK3 version:
得到GTK3版本:
dpkg -s libgtk-3-0|grep '^Version'
or just version number
或者只是版本号
dpkg -s libgtk-3-0|grep '^Version' | cut -d' ' -f2-
#4
7
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):
编译(假设上面的源文件被命名为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]#
#5
4
Try,
试,
apt-cache policy libgtk2.0-0 libgtk-3-0
or,
或者,
dpkg -l libgtk2.0-0 libgtk-3-0
#6
3
You can also just open synaptic and search for libgtk, it will show you exactly which lib is installed.
您还可以打开synaptic并搜索libgtk,它将显示安装了哪个库。
#7
2
Try:
试一试:
dpkg-query -W libgtk-3-bin
#8
1
I think a distribution-independent way is:
我认为一种独立于分配的方式是:
gtk-config --version
gtk-config——版本
#9
1
This will get the version of the GTK+ libraries for GTK+ 2 and GTK+ 3.
这将获得GTK+ 2和GTK+ 3的GTK+库的版本。
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:
由于主要版本是可并行安装的,所以您的系统上可能有这两个版本,这是我的情况,所以上面的命令在我的Ubuntu可靠系统上返回:
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.
这意味着我已经安装了GTK+ 2.24.23和3.10.8。
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——例如gtk+-3.0的modversion gtk+-3.0来实现gtk+ 3。要将其扩展到GTK+的不同主要版本(使用一些sed魔法),以下给出:
pkg-config --list-all | sed -ne 's/\(gtk+-[0-9]*.0\).*/\1/p' | xargs pkg-config --modversion
#10
0
To make the answer more general than Ubuntu (I have Redhat):
为了让答案比Ubuntu更通用(我有Redhat):
gtk is usually installed under /usr, but possibly in other locations. This should be visible in environment variables. Check with
gtk通常安装在/usr下,但也可能安装在其他位置。这在环境变量中应该是可见的。检查一下
env | grep gtk
Then try to find where your gtk files are stored. For example, use locate
and grep.
然后尝试找到您的gtk文件存储的位置。例如,使用locate和grep。
locate gtk | grep /usr/lib
In this way, I found /usr/lib64/gtk-2.0
, which contains the subdirectory 2.10.0
, which contains many .so library files. My conclusion is that I have gtk+ version 2.10. This is rather consistent with the rpm command on Redhat: rpm -qa | grep gtk2
, so I think my conclusion is right.
这样,我找到了/usr/lib64/gtk-2.0,它包含子目录2.10.0,其中包含许多.so库文件。我的结论是,我有gtk+ 2.10版本。这与Redhat的rpm命令是相当一致的:rpm -qa | grep gtk2,所以我认为我的结论是正确的。