在 Vala 中一起使用 GTK4 和 webkit2gtk 时出现大量冲突错误

Obscene amount of conflicting errors when using GTK4 and webkit2gtk together in Vala

Using the GNOME Documentation, I wanted to write a demo of using webkit and GTK4 together in Vala by porting GTK3 code. However, when changing the library from gtk3 to gtk4, a crazy amount of errors occur, 2726 in total. Most of them are very similar, seeming like library conflicts, saying "error: `Gdk' already contains a definition for ...". It seems like Webkit2GTK is on version 4 in Vala, while in Rust there is a Version 5. It also seems like they had an Experimental flag支持GTK4,但必须从源码编译,那是差不多一年前的事了。

webkit2gtk是一个将WebKit集成到GTK中的库:webkit2gtk4集成了GTK3; webkit2gtk5 将与 GTK4 一起工作。然而它还没有准备好,所以这就是为什么它在这一点上仍然是一个实验性的标志。一旦 webkit2gtk5 发布,您还必须等到 Vala 绑定发布。

换句话说,您正在使用的 library/bindings 不能 与 GTK4 一起使用,因为它不是为此而构建的。这就是为什么你有所有这些错误。