运行以下命令时,可先进入想下载安装目录。
$ git clone https://github.com/crosstool-ng/crosstool-ng
$ cd crosstool-ng/
$ ./bootstrap
$ ./configure --prefix=${PWD}
$ make
$ make install
checking for GNU libtool >= 2.4... no
configure: error: Required tool not found: libtool
安装libtool仍然无效
此时应该安装libtool-bin
$ sudo apt install libtool-bin
查看可构建的交叉编译器
$ ct-ng list-samples
使用aarch64-rpi4-linux-gnu编译器
$ ct-ng aarch64-rpi4-linux-gnu
$ ct-ng build
Build failed in step ‘Checking that gcc can statically link libstdc++ (CT_WANTS_STATIC_LINK_CXX)’
只需要安装libstdc+±11-dev(这里的11与gcc 版本对应,我本机gcc为gcc-11版本。可通过gcc -v查看)
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
···
Supported LTO compression algorithms: zlib zstd
gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)
$
$
$sudo apt install libstdc++-11-dev
如果gcc版本不同则安装不同的libstdc+±11-dev,比如,如果gcc版本为12,则安装libstdc+±12-dev
[ERROR] configure: error: C++ compiler not available, see config.log for details
缺少C++编译器安装即可
sudo apt install g++