Gtk-ERROR **: GTK+ 2.x symbols detected

自古美人都是妖i 提交于 2019-12-10 16:15:52

问题


I'm compiling my c application with gcc with the following flags:

gcc evis.c `pkg-config --cflags --libs gtk+-2.0 --libs clutter-gtk-1.0 --libs gthread-2.0` -Wall -o evis

Now my code compiles with a few warnings but still finishes. When I try to run my program I get:

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

How do I troubleshoot this error? How do I know where to look? Is there some kind of tool I could use online that would scan for GTK3 symbols in my code? I'm compiling with GTK+2 so I don't understand how this is happening.


回答1:


You are linking the same program to Gtk+2.0 and Gtk+3.0. And that will not work.

It is easy to check: just run the pkg-config command standalone. BTW, you do not need to repeat --libs so many times, and since we are looking for linking errors, I'm ommiting the --cflags for clarity:

$ pkg-config --libs gtk+-2.0 clutter-gtk-1.0 gthread-2.0

Now, it writes a lot of library names, but if you look carefully you'll find these ones:

... -lgtk-x11-2.0 ... -lgtk-3 ...

But where do they come from? Well, the Gtk+-2 part is easy: you are asking for it in the command line! The Gtk+-3 part has only one candidate:

$ pkg-config --libs clutter-gtk-1.0
... -lgtk-3 ...

Bingo! So Clutter-gtk is a Gtk+-3 library. And so should be your program is you want to use Clutter-gtk.

The solutions to your problem are:

  • Port your program to Gtk+-3 and change your compiler command accordingly.
  • Use a different version of Clutter-gtk that uses Gtk+-2. I think you can choose the dependency if you compile Clutter-gtk yourself.
  • Do not use Clutter-gtk.



回答2:


I had the same issue while using matplotlib package in python. The below code solved the issue for me

import matplotlib
matplotlib.use('Agg')


来源:https://stackoverflow.com/questions/20714343/gtk-error-gtk-2-x-symbols-detected

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!