1

我正在尝试在 Windows 10 中运行 gtkmm 程序,即使我完全按照下面所附链接提供的步骤进行编译,我也会遇到错误。

我安装了 MSYS2,运行所有命令并使用 pacman 命令安装了所有必需的软件包(我遵循了这个)。

一个程序的例子:

#include <gtkmm.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++ simple.cc -o simple `pkg-config gtkmm-3.0 --cflags --libs` 

我收到这些错误:

C:\Users\sofiane\Desktop>g++ simple.cc -o simple `pkg-config gtkmm-3.0 --cflags --libs`
g++: error: `pkg-config: No such file or directory
g++: error: gtkmm-3.0: No such file or directory
g++: error: unrecognized command line option '--cflags'
g++: error: unrecognized command line option '--libs`'
4

1 回答 1

2

似乎您的 shell 不理解反引号,并且正在考虑将它们作为命令的一部分,使其查找一个名为 `pkg-config.xml 的不存在的程序。反引号表示应该在命令行中使用 pkg-config 程序的输出。

您可能正在使用常规命令提示符而不是 MSYS shell。尝试打开 MSYS shell 窗口,或使用以下解决方法:

C:\Users\sofiane\Desktop> pkg-config gtkmm-3.0 --cflags --libs
-Ithis -Ithat -lsomething (copy and paste this line)
C:\Users\sofiane\Desktop> g++ simple.cc -o simple -Ithis -Ithat -lsomething (paste here)
于 2019-06-30T17:08:14.147 回答