【问题标题】:Why sources codes c++ in linux compile and does not start?为什么linux中的源代码c++编译不启动?
【发布时间】:2022-01-11 12:49:15
【问题描述】:

源码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>'

为什么?

【问题讨论】:

  • 您是否安装了libgtkmm 的非开发版本及其所有依赖项?

标签: c++ linux xfce gtkmm3 gtk4


【解决方案1】:

我认为您可能需要安装包gtk3-engines-xfce 或更高版本。

sudo apt update
sudo apt install gtk3-engines-xfce

【讨论】:

  • 没有。包“gtk3-engines-xfce”仅适用于 ubuntu 18.04。我有 Xubuntu 21.10。我需要解决我的问题。
  • 试试这个:gtk3-engines-unico
  • 我已经将“gtk3-engines-unico”安装到 xubuntu 21.10 并且我也有错误。
  • 您的环境中是否有一些 QT_ 变量?如果是,您可以在此处粘贴名称和值吗?
  • 我已经安装了“qt 5 dev package”apt install qtbase5-dev 我也看到了下一个错误。
猜你喜欢
  • 2023-04-06
  • 2013-11-17
  • 1970-01-01
  • 1970-01-01
  • 2014-05-24
  • 2010-10-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多