在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.

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

柳鲲鹏

能给阁下一点帮助,非常荣幸

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值