首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >让gtkmm-4.0在macOS蒙特利工作时遇到麻烦

让gtkmm-4.0在macOS蒙特利工作时遇到麻烦
EN

Stack Overflow用户
提问于 2022-02-04 02:49:47
回答 1查看 188关注 0票数 2

我很难让gtkmm-4.0在Mac蒙特利上工作。

下面是一个使用C++的简单gtkmm4应用程序。

代码语言:javascript
复制
// helloworld.cpp
#include <gtkmm.h>

class MyWindow : public Gtk::Window
{
public:
  MyWindow();
};

MyWindow::MyWindow()
{
  set_title("Basic application");
  set_default_size(200, 200);
}

int main(int argc, char* argv[])
{
  auto app = Gtk::Application::create("org.gtkmm.examples.base");

  return app->make_window_and_run<MyWindow>(argc, argv);
}

然后,我用g++编译这个应用程序,然后通过llvm-cxxfilt编写错误消息。

代码语言:javascript
复制
g++-11 helloworld.cpp -o helloworld `pkg-config --cflags --libs gtkmm-4.0`
代码语言:javascript
复制
Undefined symbols for architecture arm64:
  "Gtk::ShortcutManager::add_controller_vfunc(std::shared_ptr<Gtk::ShortcutController> const&)", referenced from:
      vtable for MyWindow in ccevdqQk.o
      construction vtable for Gtk::Window-in-MyWindow in ccevdqQk.o
      construction vtable for Gtk::ShortcutManager-in-MyWindow in ccevdqQk.o
  "Gtk::ShortcutManager::remove_controller_vfunc(std::shared_ptr<Gtk::ShortcutController> const&)", referenced from:
      vtable for MyWindow in ccevdqQk.o
      construction vtable for Gtk::Window-in-MyWindow in ccevdqQk.o
      construction vtable for Gtk::ShortcutManager-in-MyWindow in ccevdqQk.o
  "Gtk::Widget::snapshot_vfunc(std::shared_ptr<Gtk::Snapshot> const&)", referenced from:
      vtable for MyWindow in ccevdqQk.o
      construction vtable for Gtk::Window-in-MyWindow in ccevdqQk.o
      construction vtable for Gtk::Widget-in-MyWindow in ccevdqQk.o
  "Gtk::Widget::on_query_tooltip(int, int, bool, std::shared_ptr<Gtk::Tooltip> const&)", referenced from:
      vtable for MyWindow in ccevdqQk.o
      construction vtable for Gtk::Window-in-MyWindow in ccevdqQk.o
      construction vtable for Gtk::Widget-in-MyWindow in ccevdqQk.o

问题:有谁知道为什么会出现上述错误,以及如何编译C++应用程序?

这是pkg-config --cflags --libs gtkmm-4.0的输出

代码语言:javascript
复制
% pkg-config --cflags --libs gtkmm-4.0
-I/opt/homebrew/Cellar/libffi/3.4.2/include -I/opt/homebrew/Cellar/gtkmm4/4.2.0/include/gtkmm-4.0 -I/opt/homebrew/Cellar/gtkmm4/4.2.0/lib/gtkmm-4.0/include -I/opt/homebrew/Cellar/pangomm/2.50.0/include/pangomm-2.48 -I/opt/homebrew/Cellar/pangomm/2.50.0/lib/pangomm-2.48/include -I/opt/homebrew/Cellar/glibmm/2.70.0/include/giomm-2.68 -I/opt/homebrew/Cellar/glibmm/2.70.0/lib/giomm-2.68/include -I/opt/homebrew/Cellar/glibmm/2.70.0/include/glibmm-2.68 -I/opt/homebrew/Cellar/glibmm/2.70.0/lib/glibmm-2.68/include -I/opt/homebrew/Cellar/cairomm/1.16.1/include/cairomm-1.16 -I/opt/homebrew/Cellar/cairomm/1.16.1/lib/cairomm-1.16/include -I/opt/homebrew/Cellar/libsigc++/3.0.7/include/sigc++-3.0 -I/opt/homebrew/Cellar/libsigc++/3.0.7/lib/sigc++-3.0/include -I/opt/homebrew/Cellar/gtk4/4.6.0/include/gtk-4.0/unix-print -I/opt/homebrew/Cellar/gtk4/4.6.0/include/gtk-4.0 -I/opt/homebrew/Cellar/glib/2.70.3/include/gio-unix-2.0 -I/opt/homebrew/Cellar/libepoxy/1.5.9/include -I/opt/homebrew/Cellar/cairo/1.16.0_5/include/cairo -I/opt/homebrew/Cellar/pango/1.50.3/include/pango-1.0 -I/opt/homebrew/Cellar/harfbuzz/3.3.1/include/harfbuzz -I/opt/homebrew/Cellar/pango/1.50.3/include/pango-1.0 -I/opt/homebrew/Cellar/fribidi/1.0.11/include/fribidi -I/opt/homebrew/Cellar/harfbuzz/3.3.1/include/harfbuzz -I/opt/homebrew/Cellar/graphite2/1.3.14/include -I/opt/homebrew/Cellar/gdk-pixbuf/2.42.6/include/gdk-pixbuf-2.0 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/libtiff/4.3.0/include -I/opt/homebrew/Cellar/cairo/1.16.0_5/include/cairo -I/opt/homebrew/Cellar/pixman/0.40.0/include/pixman-1 -I/opt/homebrew/Cellar/fontconfig/2.13.1/include -I/opt/homebrew/opt/freetype/include/freetype2 -I/opt/homebrew/Cellar/libpng/1.6.37/include/libpng16 -I/opt/homebrew/Cellar/libxcb/1.14_1/include -I/opt/homebrew/Cellar/libxrender/0.9.10/include -I/opt/homebrew/Cellar/libxext/1.3.4/include -I/opt/homebrew/Cellar/libx11/1.7.3.1/include -I/opt/homebrew/Cellar/libxcb/1.14_1/include -I/opt/homebrew/Cellar/libxau/1.0.9/include -I/opt/homebrew/Cellar/libxdmcp/1.1.3/include -I/opt/homebrew/Cellar/graphene/1.10.6/include/graphene-1.0 -I/opt/homebrew/Cellar/graphene/1.10.6/lib/graphene-1.0/include -I/opt/homebrew/Cellar/glib/2.70.3/include -I/opt/homebrew/Cellar/glib/2.70.3/include/glib-2.0 -I/opt/homebrew/Cellar/glib/2.70.3/lib/glib-2.0/include -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/Cellar/pcre/8.45/include -I/opt/homebrew/Cellar/xorgproto/2021.5/include -L/opt/homebrew/Cellar/gtkmm4/4.2.0/lib -L/opt/homebrew/Cellar/pangomm/2.50.0/lib -L/opt/homebrew/Cellar/glibmm/2.70.0/lib -L/opt/homebrew/Cellar/cairomm/1.16.1/lib -L/opt/homebrew/Cellar/libsigc++/3.0.7/lib -L/opt/homebrew/Cellar/gtk4/4.6.0/lib -L/opt/homebrew/Cellar/pango/1.50.3/lib -L/opt/homebrew/Cellar/harfbuzz/3.3.1/lib -L/opt/homebrew/Cellar/gdk-pixbuf/2.42.6/lib -L/opt/homebrew/Cellar/cairo/1.16.0_5/lib -L/opt/homebrew/Cellar/graphene/1.10.6/lib -L/opt/homebrew/Cellar/glib/2.70.3/lib -L/opt/homebrew/opt/gettext/lib -lgtkmm-4.0 -lpangomm-2.48 -lgiomm-2.68 -lglibmm-2.68 -lcairomm-1.16 -lsigc-3.0 -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl

我使用macOS蒙特利和arm64架构。

代码语言:javascript
复制
% arch
arm64
EN

回答 1

Stack Overflow用户

发布于 2022-05-04 00:06:02

使用llvm-cxxfilt对一行编译的输出使用llvm-cxxfilt的MacOS蒙特利、Mac M1和g++ (国产GCC 11.3.0) 11.2.0

g++ helloworld.cpp -o helloworld pkg-config --cflags --libs gtkmm-4.0

架构arm64的未定义符号:

Gtk::ShortcutManager::add_controller_vfunc(std::shared_ptrGtk::ShortcutController const&)

Gtk::ShortcutManager::remove_controller_vfunc(std::shared_ptrGtk::ShortcutController const&)

Gtk::Widget::snapshot_vfunc(std::shared_ptrGtk::Snapshot const&)

Gtk::Widget::on_query_tooltip(int,int,bool,std::shared_ptrGtk::Tooltip const&)

有没有缺失的链接库?如何在MacOs上编译gtkmm4简单文件?提前谢谢你。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70980881

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档