Cross-compiler with --sys-root switch "not found"

Last edited on

Symptom

A cross-compilation build from sources runs fails when the XCXX cross-compiler variable contains a --sysroot argument:

$ ./build
sh: 1: aarch64-gnu-linux-g++ --sysroot=/home/user/sdk/sysroots/aarch64-gnu-linux: not found
Aborting build. Last command exited with status 127.

Possible Cause and Suggested Solution

Please verify the value of the XCXX environment variable:

echo $XCXX

Does it contain both the cross-compiler name as well as the --sysroot switch?

The XCXX setting should be limited to the compiler executable itself (aarch64-gnu-linux-g++ in above example). Additional switches should be specified via the CXXFLAGS switch:

XCXX=aarch64-gnu-linux-g++
export XCXX
./configure <other_switches> CXXFLAGS+="--sysroot=/home/user/sdk/sysroots/aarch64-gnu-linux"