You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

非root权限下无法运行基于GTK的OpenCV应用程序的问题求助

非root权限下无法运行基于GTK的OpenCV应用程序的问题求助

大家好,我遇到了一个棘手的问题,想请各位帮忙排查一下:

我用C++写了一个非常简单的可执行程序,依赖OpenCV和GTK3来加载并显示JPEG格式的图片。但不用sudo运行时,程序会直接报错退出,具体错误信息如下:

Gtk-WARNING **: 21:58:36.172: Could not load a pixbuf from icon theme.

This may indicate that pixbuf loaders or the mime database could not be found.

**

Gtk:ERROR:../../../../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /org/gtk/libgtk/icons/16x16/status/image-missing.png: Fatal error reading PNG image file: Invalid IHDR data (gdk-pixbuf-error-quark, 0)

Bail out! Gtk:ERROR:../../../../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /org/gtk/libgtk/icons/16x16/status/image-missing.png: Fatal error reading PNG image file: Invalid IHDR data (gdk-pixbuf-error-quark, 0)

[1] 6329 IOT instruction ./main

奇怪的是,用sudo运行时程序一切正常。

我在网上搜索了相关解决方案,尝试了所有能找到的命令,包括:

  • sudo apt reinstall libgdk-pixbuf2.0-0
  • sudo /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders --update-cache
  • sudo update-mime-database /usr/share/mime
  • sudo chmod -R uga-x /usr/share/mime; sudo chmod -R uga+X /usr/share/mime

执行完这些命令后我还重启了系统,但问题依然没有解决。

我的运行环境是WSL2下的Ubuntu 18.04,而且我在全新安装的WSL2 Ubuntu 20.04中测试了这个二进制文件,同样出现了相同的问题。

备注:内容来源于stack exchange,提问作者shelper

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 07:30:27