在Ubuntu上搭建RiscV交叉编译环境
我用的是Ubuntu22虚拟机,耗时很久。
·
- 参考文档
安装 RISC-V 交叉编译工具链 - USTC CECS 2023
- 安装依赖库
sudo apt update
sudo apt -y install autoconf automake autotools-dev curl python3 python3-pip
sudo apt -y install libmpc-dev libmpfr-dev libgmp-dev gawk
sudo apt -y install build-essential bison flex texinfo gperf libtool patchutils
sudo apt -y install bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev
- 下载代码及编译
我用的是Ubuntu22虚拟机,耗时很久。
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain
mkdir build
cd build
../configure --prefix=/opt/riscv64 --enable-multilib --target=riscv64-linux-multilib
sudo make linux -j 4
- 测试
$ echo 'export PATH=/opt/riscv64/bin:$PATH' >> ~/.bashrc
$ source ~/.bashrc
$ riscv64-unknown-linux-gnu-gcc --version
riscv64-unknown-linux-gnu-gcc (gc891d8dc23e) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
更多推荐
已为社区贡献120条内容
所有评论(0)