我正在尝试使用GTK4编译一个C应用程序。以前有人告诉这里,Ubuntu21.04和21.10都有GTK3和GTK4。但是,当我安装Ubuntu21.04时,只有GTK3出现了。然后我做了一个dist-升级到21.10,发现GTK的两个版本都是原生的:
user@user: dpkg -l libgtk* | grep -e '^i' | grep -e 'libgtk-*[0-9]'
ii libgtk-3-0:amd64 3.24.30-1ubuntu1 amd64 GTK graphical user interface library
ii libgtk-3-bin 3.24.30-1ubuntu1 amd64 programs for the GTK graphical user interface library
ii libgtk-3-common 3.24.30-1ubuntu1 all common files for the GTK graphical user interface library
ii libgtk-3-dev:amd64 3.24.30-1ubuntu1 amd64 development files for the GTK library
ii libgtk-3-doc 3.24.30-1ubuntu1 all documentation for the GTK graphical user interface library
ii libgtk-4-1:amd64 4.4.0+ds1-5 amd64 GTK graphical user interface library
ii libgtk-4-bin 4.4.0+ds1-5 amd64 programs for the GTK graphical user interface library
ii libgtk-4-common 4.4.0+ds1-5 all common files for the GTK graphical user interface library
ii libgtk2.0-0:amd64 2.24.33-2ubuntu1 amd64 GTK graphical user interface library - old version
ii libgtk2.0-bin 2.24.33-2ubuntu1 amd64 programs for the GTK graphical user interface library
ii libgtk2.0-common 2.24.33-2ubuntu1 all common files for the GTK graphical user interface library
ii libgtk3-perl 0.038-1 all Perl bindings for the GTK+ graphical user interface library只需再次检查Ubuntu产量的版本:
user@user: lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.10
Release: 21.10
Codename: impishGTK 页面要求使用以下方法来使用pkg-config编译GTK4应用程序:
gcc $( pkg-config --cflags gtk4 ) -o example-0 example-0.c $( pkg-config --libs gtk4 )这与以前的GTK版本非常相似。对于GTK3,它是:
gcc $( pkg-config --cflags gtk+-3.0 ) -o example-0 example-0.c $( pkg-config --libs gtk+-3.0 )但是,使用GTK4编译程序的结果是:
user@user: make
Package gtk4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk4.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk4' found因此,基于这里,我运行了:
user@user: pkg-config --variable pc_path pkg-config
/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig在搜索所有这些路径时,我只在/usr/lib/x86_64-linux-gnu/pkgconfig中找到与GTK相关的D10文件,而没有找到GTK4的任何内容。不过,我确实在那里找到了gtk+-3.0.pc。所以我的问题是,如果GTK4是Ubuntu21.10固有的,那么为什么pkg-config文件会丢失呢?在哪里可以获得它们,以便可以使用pkg-config进行编译?
旁白:我没有足够的声誉来创建gtk4标签。有足够声誉的人能这样做吗?
发布于 2021-11-08 17:14:11
您将需要使用以下命令安装libgtk-4-dev
sudo apt install libgtk-4-devhttps://askubuntu.com/questions/1374329
复制相似问题