0

我刚刚开始使用 wxWidgets 进行项目,并且正在尝试设置 Bakefile 以进行跨平台编译。我需要将wx-config --libs和的输出传递wx-config --cxxflags给编译器。

我怎样才能做到这一点?我在 Bakefile 文档中找不到任何关于将命令的输出转换为变量的内容。反引号似乎不起作用:

myvar = `wx-config --libs`
#=> bakefile.bkl:2:12: error: no viable alternative at character u'`'
4

1 回答 1

0

您需要在这里使用引号,即

myvar = "`wx-config --libs`"

作为参考,这是我在自己的 bakefile 中所做的:

if ( $toolset == gnu || $toolset == gnu-osx ) {
    setting WX_CONFIG {
        default = wx-config;
        help = "Path to the wx-config script";
    }

    compiler-options += "`$(WX_CONFIG) --cppflags`";
    link-options += "`$(WX_CONFIG) --libs`";
}

make WX_CONFIG=/full/path/to/wx-config这允许在使用卸载版本的 wxWidgets 时做一些方便的事情。

于 2014-12-23T09:43:21.113 回答