【问题标题】:xmake always reports: error: cannot get program for cxx, why?xmake总是报:error: cannot get program for cxx,为什么?
【发布时间】:2018-11-02 02:56:28
【问题描述】:

我在我的 Mac 上“brew install xmake”,并且有一个 .cpp 文件,我运行 xmake 并在目录中生成一个 xmake.lua。然后它报告:

error: cannot get program for cxx

我已经安装了 clang(别名为 g++)。它工作正常。然后我:

$sudo ln -s /usr/bin/g++ /usr/local/bin/cxx

嗯,再次运行xmake,还是报同样的错误:

error: cannot get program for cxx

如何处理?谢谢

------------------------我试过这些,不工作:

$xmake f -p cross

$xmake
error: cannot get program for cxx

$export CC=clang LD=clang++ xmake
$xmake
error: cannot get program for cxx

----------查看我的诊断:

$xmake f -p cross -c

(In fact no output)

$xmake -r -v
configure
{
    plat = cross
,   arch = none
,   ccache = true
,   kind = static
,   buildir = build
,   host = macosx
,   mode = release
,   clean = true
}

checking for the g++ ... no
checking for the linker (ld: g++) ... no
checking for the gcc ... no
checking for the linker (ld: gcc) ... no
checking for the clang++ ... no
checking for the linker (ld: clang++) ... no
checking for the clang ... no
checking for the linker (ld: clang) ... no
error: cannot get program for ld

$which g++
/usr/bin/g++

$which clang
/usr/bin/clang

【问题讨论】:

  • 我不确定cxx 是否适合这个问题,因为目前没有其他问题被它标记。

标签: lua g++ xmake c++


【解决方案1】:

xmake 将在 macOS 上检测并使用xcrun -sdk macosx clang。你有安装 Xcode 命令行工具吗?

如果没有,可以切换到跨平台编译。例如

xmake f -p cross
xmake

它将直接使用 gcc/clang。

或者设置--cc=clang或者CC、LD环境变量来修改编译器和链接器。

xmake f -c --cc=clang --ld=clang++
xmake

或者

导出 CC=clang LD=clang++ xmake

【讨论】:

  • 我没有安装 Xcode 命令行。但是下面的 3 种方法不起作用:(
  • 请运行xmake f -p cross -c; xmake -r -v 并给我输出信息。我需要查看更详细的日志。
  • xmake 会尝试运行clang --version 来检测clang/gcc,但似乎测试失败了。您可以尝试手动运行clang --versiong++ --version 以确认它是否有效。
  • 另外,您可以运行xmake l lib.detect.find_tool clang直接检测clang或gcc。让我看看输出信息。
【解决方案2】:

现在可以使用了,请更新到最新版本。

【讨论】:

    猜你喜欢
    • 2017-04-15
    • 1970-01-01
    • 2014-12-17
    • 2016-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-01
    • 1970-01-01
    相关资源
    最近更新 更多