xmake总是报告:错误:无法获取cxx的程序,为什么

xmake always reports: error: cannot get program for cxx, why?

本文关键字:cxx 程序 为什么 获取 报告 错误 xmake      更新时间:2023-10-16

我在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

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=叮当LD=叮当++xmake

现在可以工作了,请更新到最新版本。