-2

Source codes 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);
}

I compiled them with next command in terminal:

g++ -o main main.cpp $(pkg-config --cflags gtkmm-3.0 --libs gtk3)

and they does not start and I see next errors in console (terminal) on 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>'

Why?

Ulrich Eckhardt
  • 16,572
  • 3
  • 28
  • 55
aleks_yolp
  • 17
  • 3
  • do you have the non-dev version of `libgtkmm` installed and all its dependencies? – Mgetz Jan 11 '22 at 13:23
  • Are those `#include ` and `#include ` really necessary? It might be those headers do more than just declaring some functions and actually do register `GtkWidget` a second time and thus those warnings. – phlipsy Apr 29 '22 at 07:29

2 Answers2

0

I think you may need the package gtk3-engines-xfce or later to be installed.

sudo apt update
sudo apt install gtk3-engines-xfce
A. Ocannaille
  • 306
  • 4
  • 14
0

I don't known the reason of it. I use gtkmm on mac os and I noticed I must use "g++ -std=c++11 to compile the source, or it will failed. for your code, I think you just include <gtkmm.h> to get the program work. gtk.h and glib.h shoule be included by gtkmm.h already.

成建文
  • 13
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 30 '22 at 06:19