1
votes

After compiling and building a simple opencv program, I encountered this problem when I ran the binary file:

Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported

And these are the results of running pkg-config

pkg-config --libs gtk+-2.0

gives me

-lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype

pkg-config --libs gtk+-3.0

gives me

-lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0

1

1 Answers

3
votes

Possibly one of your libraries you are linking with uses gtk 3.0. Have you tried to track down which of version each of these libs are using? Maybe they all are using version 2 and you yourself is using a version 3. Do you get this error when you are linking or when you are running? ldd will show the runtime usage of libs.

As an example, I want to know if its my code which uses version 3 of the gtk library or one of the libraries I am using which uses version 3 of gtk library.

So first I'm going to run ldd to see which libs my exe uses at runtime.

$ ldd /usr/bin/gkrellm | head
    linux-vdso.so.1 =>  (0x00007ffe57d03000)
    libgtk-x11-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 (0x00007f5c88b55000)
    libgdk-x11-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0 (0x00007f5c888a0000)
    libgdk_pixbuf-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007f5c8867d000)
    libpango-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007f5c88431000)

I've truncated the output using head, but here its showing the exe is uses gtk version 2 lib. But is it because my exe links against it or because one of the libs I'm using uses it?

Lets try the libpango lib.

$ readelf -d /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 | grep library
0x0000000000000001 (NEEDED)             Shared library: [libgobject-2.0.so.0]
0x0000000000000001 (NEEDED)             Shared library: [libglib-2.0.so.0]
0x0000000000000001 (NEEDED)             Shared library: [libthai.so.0]
0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

If I repeat this process, I'll see that in this case libgtk is not used by any of the subsquent libs and so the gtk lib is called in by the source for gkrellm itself.

In your case, I suspect you have libs which use one version but your code is using a different version.