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

  • 参考文档

安装 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.

相关推荐

  1. UbuntuRiscV交叉编译环境

    2023-12-07 21:28:02       393 阅读
  2. 基于 Docker 交叉编译环境

    2023-12-07 21:28:02       62 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-07 21:28:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-07 21:28:02       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-07 21:28:02       82 阅读
  4. Python语言-面向对象

    2023-12-07 21:28:02       91 阅读

热门阅读

  1. AISchedule(4):番茄钟功能

    2023-12-07 21:28:02       50 阅读
  2. .Net 字符集与编解码

    2023-12-07 21:28:02       43 阅读
  3. 聊聊springboot的logging.group

    2023-12-07 21:28:02       53 阅读
  4. C++基础 std::Move简说

    2023-12-07 21:28:02       67 阅读
  5. 关于 Static 静态关键字的使用,你了解多少?

    2023-12-07 21:28:02       61 阅读
  6. 《计算理论导引(原书第3版)》笔记

    2023-12-07 21:28:02       50 阅读
  7. GaussDB数据库SQL系列-LOCK TABLE

    2023-12-07 21:28:02       48 阅读