当前位置: 首页 > news >正文

Ubuntu22.04 交叉编译GCC13.2.0 for Rv1126

一、安装Ubuntu22.04 

sudo apt install vim net-tools openssh-server

二、安装必要项

sudo apt update
sudo apt upgrade
sudo apt install build-essential gawk git texinfo bison flex

三、下载必备软件包

1.glibc

https://ftp.gnu.org/gnu/glibc/glibc-2.38.tar.gz

 2.gcc

https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.gz

3.binutils

 https://ftp.gnu.org/gnu/binutils/binutils-2.41.tar.xz

4.Linux kernel

https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/linux-6.6.tar.gz

下载完成后存在在/opt目录下

四、在/opt目录下创建编译文件夹,且解压文件

mkdir build-gcc
mkdir build-glibc
mkdir build-utils
mkdir packet #gcc 打包目录

 

五、下载gcc依赖包

cd /opt/gcc-13.2.0/
./contrib/download_prerequisites

这里主要下载的是gmp、mpfr、mpc、isl等库

六、安装内核头文件

cd /opt/linux-6.6
make ARCH=arm INSTALL_HDR_PATH=/opt/packet/arm-linux-gnueabihf headers_install

rv1126 是32位的板子,故ARCH=arm,如需要64位的板子则:

make ARCH=arm64 INSTALL_HDR_PATH=/opt/packet/arm-linux-gnueabihf headers_install

七、编译binutils

cd /opt/build-utils
../binutils-2.41/configure --prefix=/opt/packet --target=arm-linux-gnueabihf --with-arch=armv7l --with-fpu=vfp --with-float=hard --disable-multilib
make
make install

rv1126的板子是armv7l, 故 --with-arch=armv7l

 

八、部分编译gcc

cd /opt/build-gcc
#../gcc-13.2.0/configure --prefix=/opt/packet --target=arm-linux-gnueabihf --enable-languages=c,c++,fortran  --with-fpu=vfp --with-float=hard --disable-multilib../gcc-13.2.0/configure --prefix=/opt/packet --target=arm-linux-gnueabihf --enable-languages=c,c++ --with-fpu=vfp --with-float=hard --disable-multilib --enable-libstdcxx  --enable-libgm2 --enable-libssp  --enable-sharedmake -j8 all-gcc
make install-gcc

九、部分编译glibc

cd /opt/build-glibcexport PATH=$PATH:/opt/packet/bin../glibc-2.38/configure \--prefix=/opt/packet/arm-linux-gnueabihf \--build=$MACHTYPE \--host=arm-linux-gnueabihf \--target=arm-linux-gnueabihf \--with-arch=armv7l \--with-fpu=vfp \--with-float=hard \--with-headers=/opt/packet/arm-linux-gnueabihf/include \--disable-multilib \libc_cv_forced_unwind=yesmake install-bootstrap-headers=yes install-headers make -j8 csu/subdir_libinstall csu/crt1.o csu/crti.o csu/crtn.o /opt/packet/arm-linux-gnueabihf/libarm-linux-gnueabihf-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /opt/packet/arm-linux-gnueabihf/lib/libc.sotouch /opt/packet/arm-linux-gnueabihf/include/gnu/stubs.h

 

十、接着部分编译gcc

cd /opt/build-gcc
make -j8 all-target-libgcc
make install-target-libgcc

 

十一、全编译glibc 

cd /opt/build-glibcexport PATH=$PATH:/opt/packet/binmake -j8make install

十二、全编译gcc

cd /opt/build-gcc
make -j8 all-target-libgcc
make install-target-libgcc

查看文件

十三、测试

1.创建build.sh

#!/bin/bash/opt/packet/bin/arm-linux-gnueabihf-g++ test.cpp -o ./test -lpthread

 2.创建test.cpp

#include <stdio.h>
#include <thread>
#include <mutex>
#include <unistd.h>
#include <vector>
#include <algorithm>
using namespace std;std::mutex g_mutex;
std::vector<int>g_vData;void process()
{int n = 0;while(true){g_mutex.lock();g_vData.push_back(n++);g_mutex.unlock();}
}void Process1()
{while(true){g_mutex.lock();if(g_vData.size() > 0){std::vector<int>::iterator iter = g_vData.begin();printf("%d\n", *iter);g_vData.erase(iter);}g_mutex.unlock();}
}int main()
{printf("hello\n");std::thread* pthread = new std::thread(process);std::thread* pthread1 = new std::thread(Process1);sleep(-1);return 0;
}

3.执行

sudo chmod 777 ./build.sh
./build.sh

4.将test这个执行程序拷贝到arm板

十四、参考链接

aarch64-linux-gnu_交叉编译工具链_gcc-9.3.0-x86_64_arrch64-linux-gnu-CSDN博客

创建飞腾CPU的交叉编译环境_飞腾内核编译-CSDN博客

交叉编译生成可以在ARM64平台上运行的gcc_gdb arm64交叉编译-CSDN博客

http://www.lryc.cn/news/238001.html

相关文章:

  • 什么是EVM?以太坊EVM合约交互
  • Vue Treeselect el-tree-select 多选 只选中第三级
  • Stable Diffusion专场公开课
  • 【Typroa使用】Typroa+PicGo-Core(command line)+gitee免费图片上传配置
  • 【云原生-Kurbernetes篇】HPA 与 Rancher管理工具
  • Python学习笔记(4)
  • 算法通关村第十二关-青铜挑战字符串
  • 网站被反诈拦截该怎么申诉与解封
  • 【机器学习】033_反向传播
  • 关于缓存和数据库一致性问题的深入研究
  • vim模式用法总结
  • 基于深度学习的单帧图像超分辨率重建综述
  • 开源与闭源:创新与安全的平衡
  • C# 22H2之后的windows版本使用SetDynamicTimeZoneInformation设置时区失败处理
  • 分布式与微服务 —— 初始
  • 多因素方差分析(Multi-way Analysis of Variance) R实现
  • git撤销某一次commit提交
  • 数据结构详细笔记——图
  • 黑马React18: 基础Part II
  • Maven工程继承关系,多个模块要使用同一个框架,它们应该是同一个版本,项目中使用的框架版本需要统一管理。
  • Selenium UI 自动化
  • 竞赛 题目:基于深度学习的图像风格迁移 - [ 卷积神经网络 机器视觉 ]
  • 【unity3D-网格编程】01:Mesh基础属性以及用代码创建一个三角形
  • Java贪吃蛇小游戏
  • Linux:系统基本信息扫描(1)
  • VR全景打造亮眼吸睛创意内容:三维模型、实景建模
  • ProTable高级表格获取表单数据
  • 力扣刷题第二十七天--二叉树
  • 一个快递包裹的跨国之旅
  • qsort函数使用方法总结