【问题标题】:Compile gtkmm program with command line?用命令行编译gtkmm程序?
【发布时间】:2019-06-03 18:47:55
【问题描述】:

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

我安装了 MSYS2,我运行了所有命令并使用 pacman 命令安装了所有必需的包(我关注了this)。

一个程序示例:

#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);
}

使用命令行执行时的错误消息(找到here):

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`'

【问题讨论】:

  • 如果没有 pkg-config 二进制文件,您将无法调用该命令。如果它不在您的 PATH 中,请找出它的位置和/或安装它。

标签: c++ gtkmm3


【解决方案1】:

您的 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)

【讨论】:

    猜你喜欢
    • 2010-11-24
    • 1970-01-01
    • 2012-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-16
    • 2016-02-02
    • 1970-01-01
    相关资源
    最近更新 更多