Try,
apt-cache policy libgtk2.0-0 libgtk-3-0
or,
dpkg -l libgtk2.0-0 libgtk-3-0
Because apt-cache policy
will list all the matches available, even if not installed, I would suggest using this command for a more manageable shortlist of GTK-related packages installed on your system:
apt list --installed libgtk*
You can use this command:
$ dpkg -s libgtk2.0-0|grep '^Version'
This isn't so difficult.
Just check your gtk+ toolkit utilities version from terminal:
gtk-launch --version
get GTK3 version:
dpkg -s libgtk-3-0|grep '^Version'
or just version number
dpkg -s libgtk-3-0|grep '^Version' | cut -d' ' -f2-
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
I think a distribution-independent way is:
gtk-config --version
To make the answer more general than Ubuntu (I have Redhat):
gtk is usually installed under /usr, but possibly in other locations. This should be visible in environment variables. Check with
env | grep gtk
Then try to find where your gtk files are stored. For example, use locate
and 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.
Try:
dpkg-query -W libgtk-3-bin
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]#
You can also just open synaptic and search for libgtk, it will show you exactly which lib is installed.
Source: Stackoverflow.com