简体   繁体   English

opencv错误:检测到GTK + 2.x符号。 不支持在同一过程中使用GTK + 2.x和GTK + 3

[英]opencv error: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported

After compiling and building a simple opencv program, I encountered this problem when I ran the binary file: 编译并构建了一个简单的opencv程序后,运行二进制文件时遇到了以下问题:

Gtk-ERROR **: GTK+ 2.x symbols detected. Gtk-ERROR **:检测到GTK + 2.x符号。 Using GTK+ 2.x and GTK+ 3 in the same process is not supported 不支持在同一过程中使用GTK + 2.x和GTK + 3

And these are the results of running pkg-config 这些是运行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 -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 -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

Possibly one of your libraries you are linking with uses gtk 3.0. 您可能要链接的其中一个库使用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? 也许他们都使用版本2,而您自己使用的是版本3。在链接或运行时会收到此错误吗? ldd will show the runtime usage of libs. ldd将显示库的运行时用法。

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. 例如,我想知道其代码是使用gtk库的版本3还是我正在使用的其中一个库使用gtk库的版本3。

So first I'm going to run ldd to see which libs my exe uses at runtime. 所以首先我要运行ldd来查看我的exe在运行时使用哪个库。

$ 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. 我已经用head截断了输出,但是这里显示的exe是使用gtk版本2 lib。 But is it because my exe links against it or because one of the libs I'm using uses it? 但这是因为我的exe链接到它还是因为我正在使用的一个库使用它吗?

Lets try the libpango lib. 让我们尝试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. 如果我重复此过程,我会发现在这种情况下,任何后续的lib都不会使用libgtk,因此gkrellm本身的源将调用gtk lib。

In your case, I suspect you have libs which use one version but your code is using a different version. 在您的情况下,我怀疑您有使用一个版本的库,但是您的代码使用了另一个版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM