ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

在Ubuntu上搭建RiscV交叉编译环境

2026/9/13 16:55:28 拓冰建站 浏览量
在Ubuntu上搭建RiscV交叉编译环境
  • 参考文档

安装 RISC-V 交叉编译工具链 - USTC CECS 2023

  • 安装依赖库
sudo apt updatesudo 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.