views:

6187

answers:

4

I need to determine which version of GTK Ubuntu is using.

Man does not seem to help

+5  A: 
$ dpkg -s libgtk2.0-0|grep '^Version'
Torsten Marek
+7  A: 

The above 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[0-9]* | grep ^i

to list all the libgtk packags, 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.

Mark Baker
A: 

I think a distribution-independent way is:

gtk-config --version

Xqj37
While gtk-config is distribution independent, it only works for GTK 1.x. The correct way for newer versions is to use pkg-config, as I said in my answer.
Mark Baker
A: 

You can also just open synaptic and search for libgtk, it will show you exactly which lib is installed.

Luka Marinko