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

930 Views Asked by At

I've "brew install xmake" on my mac, and having a .cpp file, I run xmake and it generates a xmake.lua in the directory. Then it reports:

error: cannot get program for cxx

I've installed clang (alias as g++). It works fine. I then:

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

Well, running xmake again, but it still reports same error:

error: cannot get program for cxx

How to handle this? Thanks

----------------------I tried these, don't work:

$xmake f -p cross

$xmake
error: cannot get program for cxx

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

----------------------See my diagnotics:

$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
2

There are 2 best solutions below

4
ruki On

xmake will detect and use xcrun -sdk macosx clang on macOS. Do you have Xcode command line tools installed?

If not, you can switch to cross platform to compile it. for example

xmake f -p cross
xmake

It will use gcc/clang directly.

Or set --cc=clang or CC, LD envirnoment vars to modify compiler and linker.

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

Or

export CC=clang LD=clang++ xmake

0
Ruki Wang On

It works now, please update to latest version.