Error:Qt调用gtk报错: gtk+-2.0 development package not found

本文介绍了解决在Qt工程中加载GTK函数时报错的问题,详细步骤包括使用sudo apt install gtk+-2.0命令安装GTK2.0库,并调整PKG_CONFIG_PATH环境变量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用:

CONFIG += c++11 link_pkgconfig
PKGCONFIG += gtk+-2.0

在qt工程中加载gtk函数,报错:

gtk+-2.0 development package not found

原因是没有安装gtk2.0的库。
使用下面命令进行安装:

sudo apt install gtk+-2.0

安装完成之后,就可以使用了。


未安装之前:

adams@adams-pc:~/$ pkg-config --cflags --libs gtk+-2.0
Package gtk+-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-2.0' found
adams@adams-pc:~/$ pkg-config --cflags --libs gtk+-3.0
-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/libdrm -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -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
adams@adams-pc:~/$
Processing /home/luli/DH-PTAM-master/pangolin Preparing metadata (setup.py) ... done Building wheels for collected packages: pangolin Building wheel for pangolin (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [41 lines of output] running bdist_wheel running build running build_py /home/luli/anaconda3/envs/dhptam/lib/python3.8/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. !! ******************************************************************************** Please avoid running ``setup.py`` directly. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. ******************************************************************************** !! self.initialize_options() installing to build/bdist.linux-x86_64/wheel running install copying ./pangolin.cpython-38-x86_64-linux-gnu.so -> / Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "/home/luli/DH-PTAM-master/pangolin/setup.py", line 30, in <module> setup( File "/home/luli/anaconda3/envs/dhptam/lib/python3.8/site-packages/setuptools/__init__.py", line 117, in setup return distutils.core.setup(**attrs) File "/home/luli/anaconda3/envs/dhptam/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 183, in setup return run_commands(dist) File "/home/luli/anaconda3/envs/dhptam/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 199, in run_commands dist.run_commands() File "/home/luli/anaconda3/envs/dhptam/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands self.run_command(cmd) File "/home/luli/anaconda3/envs/dhptam/lib/python3.8/site-packages/setuptools/dist.py", line 999, in run_command super().run_command(command) File "/home/luli/anaconda3/envs/dhptam/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 973, in run_command cmd_obj.run() File "/home/luli/anaconda3/envs/dhptam/lib/python3.8/site-packages/setuptools/command/bdist_wheel.py", line 461, in run self.egg2dist(self.egginfo_dir, distinfo_dir) File "/home/luli/anaconda3/envs/dhptam/lib/python3.8/site-packages/setuptools/command/bdist_wheel.py", line 590, in egg2dist raise ValueError(err) ValueError: Egg metadata expected at build/bdist.linux-x86_64/wheel/./pangolin-0.0.1-py3.8.egg-info but not found [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pangolin Running setup.py clean for pangolin Failed to build pangolin ERROR: Failed to build installable wheels for some pyproject.toml based projects (pangolin) (dhptam) luli@l
最新发布
05-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值