源码c++ gtkmm3 gtk4 linux:
#include <gtkmm.h>
#include <gtk/gtk.h>
#include <glib.h>
int main(int argc, char *argv[])
{
auto app =
Gtk::Application::create(argc, argv,
"org.gtkmm.examples.base");
Gtk::Window window;
window.set_default_size(200, 200);
return app->run(window);
}
我在终端中使用下一个命令编译它们:
g++ -o main main.cpp $(pkg-config --cflags gtkmm-3.0 --libs gtk3)
他们没有启动,我在 xubuntu 21.10 xfce (xfce4-panel 4.16.3 (Xfce 4.16)) 上的控制台(终端)中看到下一个错误
user@myPC:~$ ./main
(process:39732): GLib-GObject-WARNING **: 18:55:52.593: cannot register existing type 'GtkWidget'
(process:39732): GLib-GObject-WARNING **: 18:55:52.593: cannot add class private field to invalid type '<invalid>'
(process:39732): GLib-GObject-WARNING **: 18:55:52.593: cannot add private field to invalid (non-instantiatable) type '<invalid>'
(process:39732): GLib-GObject-CRITICAL **: 18:55:52.593: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
(process:39732): GLib-GObject-WARNING **: 18:55:52.593: cannot register existing type 'GtkBuildable'
(process:39732): GLib-GObject-CRITICAL **: 18:55:52.593: g_type_interface_add_prerequisite: assertion 'G_TYPE_IS_INTERFACE (interface_type)' failed
(process:39732): GLib-CRITICAL **: 18:55:52.593: g_once_init_leave: assertion 'result != 0' failed
(process:39732): GLib-GObject-CRITICAL **: 18:55:52.593: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
(process:39732): GLib-GObject-CRITICAL **: 18:55:52.593: g_type_register_static: assertion 'parent_type > 0' failed
(process:39732): GLib-GObject-WARNING **: 18:55:52.593: cannot add private field to invalid (non-instantiatable) type '<invalid>'
(process:39732): GLib-CRITICAL **: 18:55:52.593: g_once_init_leave: assertion 'result != 0' failed
(process:39732): GLib-GObject-CRITICAL **: 18:55:52.593: g_type_register_static: assertion 'parent_type > 0' failed
(process:39732): GLib-GObject-WARNING **: 18:55:52.593: cannot add private field to invalid (non-instantiatable) type '<invalid>'
为什么?