riscv-gnu-toolchain 交叉编译器如何构建?

安装依赖工具

shell 复制代码
sudo apt-get install git autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf patchutils bc libexpat-dev libglib2.0-dev ninja-build zlib1g-dev pkg-config libboost-all-dev libtool libssl-dev libpixman-1-dev libpython-dev virtualenv libmount-dev libsdl2-dev

工具链下载

开始下载 riscv-gnu-toolchain

shell 复制代码
git clone https://gitee.com/mirrors/riscv-gnu-toolchain
cd riscv-gnu-toolchain

下载 RISC-V 平台的 C 语言编译器源代码仓库

shell 复制代码
git clone -b riscv-gcc-10.2.0 https://gitee.com/mirrors/riscv-gcc

下载测试框架源代码仓库,即 riscv-dejagnu

shell 复制代码
git clone https://gitee.com/mirrors/riscv-dejagnu

下载 GNU 的 C 库源代码仓库,也就是 riscv-glibc

shell 复制代码
git clone -b riscv-glibc-2.29 https://gitee.com/mirrors/riscv-glibc

下载用于嵌入式的轻量级 C 库源代码仓库,即 riscv-newlib

shell 复制代码
git clone https://gitee.com/mirrors/riscv-newlib

下载二进制工具集合源代码仓库 riscv-binutils

shell 复制代码
git clone -b riscv-binutils-2.35 https://gitee.com/mirrors/riscv-binutils-gdb riscv-binutils

下载 GDB 软件调试器源代码仓库 riscv-gdb

shell 复制代码
git clone -b fsf-gdb-10.1-with-sim https://gitee.com/mirrors/riscv-binutils-gdb riscv-gdb

配置工具链

shell 复制代码
kdir build  #建立build目录
#配置操作,终端一定要切换到build目录下再执行如下指令
../configure --prefix=/opt/riscv/gcc --enable-multilib --target=riscv64-multlib-elf

编译工具链

sudo make -j8

这个指令在编译完成后会自动安装到"/opt/riscv/gcc"目录,由于要操作"/opt/riscv/gcc"目录需要超级管理员权限,所以我们要记得加上 sudo

切换到"/opt/riscv/gcc/bin"目录下,执行如下指令

shell 复制代码
riscv64-unknown-elf-gcc -v

看是否有riscv64-unknown-elf-gcc版本信息

相关推荐
爱技术的小伙子1 分钟前
Linux 磁盘管理与分区:使用fdisk、parted、df、du等命令管理磁盘和分区
linux·运维·服务器
Java小白白同学3 分钟前
Linux:CentOS 系统磁盘扩容操作
linux·服务器·centos
semicolon_hello8 分钟前
使用C++编写TCP服务端程序
服务器·网络·c++·tcp/ip
不喜欢就睡大觉20 分钟前
Linux—网络设置
linux·运维·服务器
Roc-xb20 分钟前
使用ifconfig命令获取当前服务器的内网IP地址
运维·服务器·tcp/ip
qq_17780362221 分钟前
Windows系统服务器远程教程
运维·服务器·云计算·ddos·ip
我爱小白羊23 分钟前
【Linux】进程优先级 + 环境变量
linux·运维·服务器
seetimee24 分钟前
服务器工具集合推荐
运维·服务器
TheJustice_28 分钟前
Linux 常用指令详解
linux·运维·服务器
fs哆哆33 分钟前
ExcelVBA运用Excel的【条件格式】(二)
linux·运维·服务器·前端·excel