树莓派交叉编译知识_deb交叉编译-程序员宅基地

技术标签: 单片机ARM  arduino 树莓派 IOT  

https://github.com/abhiTronix/raspberry-pi-cross-compilers

 

关键字:Recipes  ubuntu12

步骤1.构建工具链

由于我们要在具有Intel处理器的笔记本电脑上运行,并且我们希望在Raspberry Pi的核心上为ARM处理器构建目标代码,因此我们需要一个交叉编译器及其相关工具,通常称为“工具链”。 ”。在这里,我们使用“ crosstool-ng ”来构建这种工具链。

遵循安德鲁的建议,下面的许多说明都遵循克里斯·博特的这篇文章:http :
//www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-树莓派/

 

步骤1.1下载crosstool-ng

我们转到:http : //crosstool-ng.org/#download_and_usage

并下载最新版本,在撰写此博客时为:  1.17.0
请注意,在下载页面中,版本号按字母顺序(而不是数字)排序。
在我的第一次访问中,我直接进入页面底部并错误地获取了1.9.3版,
因为它位于页面底部…

下面的链接,按日期对下载进行了排序,可能对您有用:

文件00-LATEST-is-1.17.0也应该是一个提示……如果我注意的话……

We created a directory to host it and then downloaded and extracted the sources by doing:

  • mkdir -p  ~/src/RaspberryPi/toolchain
  • cd ~/src/RaspberryPi/toolchain
  • wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.17.0.tar.bz2
  • tar xjf crosstool-ng-1.17.0.tar.bz2
  • cd crosstool-ng-1.17.0

 

Step 1.2 Configure and Build

Here we continue following Chris Boot’s instructions.

We chose to configure the tool to be installed in a local directory inside our home directory.

  • cd ~/src/RaspberryPi/toolchain/crosstool-ng-1.17.0
  • mkdir -p ~/local/crosstool-ng
  • ./configure –prefix=/home/ibanez/local/crosstool-ng

to get this to work, we had to install the following Ubuntu packages (most of which were listed in Andrew’s recipe),

  • bison
  • cvs
  • flex
  • gperf
  • texinfo
  • automake
  • libtool

The whole is done with the command:

  • sudo aptitude install bison cvs flex gperf texinfo automake libtool

then we can do

  • make
  • make install

and add to the PATH the bin directory where crosstool-ng was installed:

  • export PATH=$PATH:/home/ibanez/local/crosstool-ng/bin/

In some cases, it might be necessary to unset the LD_LIBRARY_PATH,
to prevent the toolchain from grabbing other shared libraries from the host machine:

  • unset LD_LIBRARY_PATH

Step 1.3 Build Raspberry Toolchain

Create a staging directory. This is a temporary directory where the toolchain will be configured and built, but it is not its final installation place.

  • mkdir -p ~/src/RaspberryPi/staging
  • cd ~/src/RaspberryPi/staging/
  • ct-ng  menuconfig

 

https://blog.kitware.com/cross-compiling-for-raspberry-pi/

Then, start the build process by typing

  • ct-ng  build

It was nice to see that the build projects uses the proper “make -j ” options for parallel building
and therefore makes use of all the available cores:

Step 1.4 Build the C++ compiler in the toolchain

By default, our process above only built the C compiler.

We are now going to build the C++ compiler as well.

To build the C++ compiler we do the following:

  • We go back to the staging directory:
    /home/ibanez/src/RaspberryPi/staging
  • and run the configuration process
    ct-ng menuconfig
  • We go into the “C compiler” option Enable the option “C++”
  • Save and Exit
  • and type again
    “ct-ng  build”
    to build the toolchain.
  • This completes the set up of the tool chain.

    We are now ready to use CMake to cross compile bigger projects.

Then, we can change directories to the bin directory and configure with CMake, by pointing to the toolchain file as:

  • cd /tmp/hello/bin
  • cmake -DCMAKE_TOOLCHAIN_FILE=/home/ibanez/bin/RaspberryPi/CMakeToolChain/Toolchain-RaspberryPi.cmake ../src
  • and simply build with “make”
  • Then copy the resulting executable to the Raspberry Pi, and run it.

Step 3. Setting up additional bin and lib files for cross compiling.

If you need access to the libraries on the RaspberryPi for compiling
(for example if you have built the latest boost libriaries on the RaspberryPi
and it is installed in /usr/local), you can copy these to a directory on your
host computer using rsync that will preserve the symlinks.

  • On your host machine you may also have to install rsync
    •  sudo aptitude install rsync
  • On the RaspberryPi install rsync:
    •  sudo apt-get istall rsync
  • Create a folder on the cross compiling machine. For example, here we call it: ~/bin/RaspberryPi
    • mkdir -p ~/bin/RaspberryPi
  • cd to this folder
    • cd  ~/bin/RaspberryPi
  • and do the following:

Remember to run these rsync commands whenever new libraries are added to the RaspberryPi system or when the RaspberryPi is upgraded.

 

内核编译

https://www.raspberrypi.org/documentation/linux/kernel/building.md

  • 更新中
    • 在Raspberry Pi上更新Linux内核
  • 建造
    • 在Raspberry Pi上构建Linux内核
  • 配置中
    • 在Raspberry Pi上配置Linux内核
  • 打补丁
    • 在Raspberry Pi上将补丁应用到Linux内核
  • 标头
    • 获取内核头文件

在Raspberry Pi 4上安装64位Debian

https://david.wragg.org/blog/2020/01/installing-64-bit-debian-on-rpi.html

https://raspi.debian.net/

交叉编译C/c++

https://medium.com/@au42/the-useful-raspberrypi-cross-compile-guide-ea56054de187

https://desertbot.io/blog/how-to-cross-compile-for-raspberry-pi  docker

https://hackaday.com/2016/02/03/code-craft-cross-compiling-for-the-raspberry-pi/   cmake

http://amgaera.github.io/blog/2014/04/10/cross-compiling-for-raspberry-pi-on-64-bit-linux/   cmake

https://visualgdb.com/tutorials/raspberry/crosscompiler/

https://www.codeproject.com/Articles/1279667/Toolset-to-cross-compile-remote-debug-Raspberry-fr windows

交叉编译python环境

 

 

交叉编译QT

Step 3. Setting up additional bin and lib files for cross compiling.

If you need access to the libraries on the RaspberryPi for compiling
(for example if you have built the latest boost libriaries on the RaspberryPi
and it is installed in /usr/local), you can copy these to a directory on your
host computer using rsync that will preserve the symlinks.

  • On your host machine you may also have to install rsync
    •  sudo aptitude install rsync
  • On the RaspberryPi install rsync:
    •  sudo apt-get istall rsync
  • Create a folder on the cross compiling machine. For example, here we call it: ~/bin/RaspberryPi
    • mkdir -p ~/bin/RaspberryPi
  • cd to this folder
    • cd  ~/bin/RaspberryPi
  • and do the following:

Remember to run these rsync commands whenever new libraries are added to the RaspberryPi system or when the RaspberryPi is upgraded.

https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/

It is assumed that you have a SD card with Raspbian strech installed in your Raspberry Pi, otherwise download it and follow the installation guide. Also, check that you have the latest firmware, or install it and reboot the system. Execute the following command in the Raspberry Pi command-line interface for updating the firmware.

sudo rpi-update

reboot

Make sure that you have activated the Secure Shell (SSH) protocol in Raspbian. We will need it later to comunicate Qt Creator with your Raspbery Pi.

sudo raspi-config

Select Interfacing Options, select ssh, choose yes and finish.

The following list summarizes the main steps to cross-compile Qt 5.12 for Raspberry Pi, we will be describing each of them in this post. The [Pi] label means this action is done in the Raspberry Pi, whereas [Co] means it has to be performed in you computer.

  1. Install development libraries – [Pi]
  2. Prepare target folder – [Pi]
  3. Create working folder and set a toolchain – [Co]
  4. Create and configure a sysroot – [Co]
  5. Download Qt – [Co]
  6. Configure Qt for cross compilation – [Co]
  7. Compile, install and deploy Qt – [Co]
  8. Setup Qt Creator for Raspberry Pi cross compilation – [Co]

制作arm版本的deb包

 

https://raspberrypi.stackexchange.com/questions/5524/tutorial-on-crosscompiling-deb-packages

 

构建针对Debian或Rasbian的.deb软件包的推荐方法是在计算机上或仿真的计算机内编译软件包。因此,为Raspberry Pi交叉编译.deb的推荐方法是在X86机器上使用qemu模拟一个完整的系统,然后使用它进行编译。 http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/(archive.org副本)

最新的Debian和Ubuntu sbuild工具中内置了真正的交叉编译支持,可用于编译或交叉编译.deb软件包,您可以通过遵循最新的Debian / Ubuntu Wiki指南来了解如何使用sbuild的交叉编译功能。(假设您正在运行最新的Debian或Ubuntu开发分支)。 http://wiki.debian.org/CrossBuildPackagingGuidelines https://wiki.ubuntu.com/CrossBuilding

 

 

https://stackoverflow.com/questions/21564768/how-to-cross-compile-debian-package-for-arm-raspberry-pi

第一种方法是使用与Raspberry Pi Debian相同的主机Debian发行版。例如7.0。添加deb http://www.emdebian.org/debian/ unstable main 至您/etc/apt/sources.list并安装工具链:

apt-get update
apt-get install emdebian-archive-keyring
apt-get install gcc-4.7-arm-linux-gnueabihf g++-4.7-arm-linux-gnueabihf
apt-get install build-essential git debootstrap u-boot-tools

然后,可以通过xapt安装交叉编译的依赖项。也许您dpkg-buildpackage那时就可以使用。

替代方案:

您可以将软件包转换为使用CMake并使用CPack生成一个deb文件。这种方法也适用于其他发行版,例如openSuSe,Fedora。

更新:

随着Emdebian发行版更新的停止,建议切换到较新的Debian版本并使用多体系结构功能。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/liang890319/article/details/108925433

智能推荐

九度OJ 1038:Sum of Factorials(阶乘的和) (DP、递归)-程序员宅基地

时间限制:1 秒内存限制:32 兆特殊判题:否提交:1845解决:780题目描述: John von Neumann, b. Dec. 28, 1903, d. Feb. 8, 1957, was a Hungarian-American mathematician who made important contri...

基于BiLinear的VGG16+ResNet50,用于细粒度图像分类-程序员宅基地

细粒度视觉识别之双线性CNN模型[1] Lin T Y, RoyChowdhury A, Maji S. Bilinear cnn models for fine-grained visual recognition[C]//Proceedings of the IEEE International Conference on Computer Vision. 2015: 1449-1457....

系统上线Release分支发布流程(不同公司流程规范不一样,仅供参考)-程序员宅基地

前言:为了规范公司的版本管理,防止代码夹带现象出现,并向优秀公司学习版本管理流程。公司决定以小程序作为版本控制流程试点,这里也是以小程序为例!一、流程图二、描述1、开发将master的内容同步至fature分支上进行功能开发,当功能全部转测之后,开发将从fature分支创建release分支,完成之后,测试将创建分支的权限回收(通过将该release分支设置为保护分支。)以后开发每次需要向release分支提交内容时,需要找测试进行申请,测试将给开发临时权限(将该release分支从保护分支中解除_release分支

VUE使用element UI的upload组件时ios上传图片旋转90度问题_elementui 上传旋转-程序员宅基地

vue使用Upload组件上传图片 <Upload class="upload" :show-file-list="false" :action="getUploadUrl" :before-upload="beforeUpLoad" ..._elementui 上传旋转

python 局部变量和全局变量的区别 小甲鱼019_python局部变量和全局变量的区别-程序员宅基地

理解:什么是局部变量,什么是全局变量局部变量的定义:在局部范围内的变量;例子:天气预报:西安2019年7月19号今天阴天,在全国范围内,今天的天气是阴天。(对于西安今天是阴天,但是明天就是晴天。只保证今天是阴天)全局变量的定义:在全局范围内的变量:例子:城市省会,西安是陕西的省会(在国家范围内西安就是陕西省省会,一直是,基本不变)我定义了3个函数,a=3为全局变量,如果局部不改变a的值则a就..._python局部变量和全局变量的区别

struct addrinfo结构体获取ip和port-程序员宅基地

表头文件: #includestruct addrinfo{ int ai_flags; int ai_family; //AF_INET,AF_INET6,UNIX etcint ai_socktype; //STREAM,DATAGRAM,RAWint ai_protocol; //IPPROTO_IP, IPPROTO_IPV4, IPPROTO_IPV6 etc_struct addrinfo

随便推点

Qt中QTabWidget隐藏某些tab_qt settabenabled-程序员宅基地

对于一个QTabWidget,有时我们需要在不同的状态下显示不同的tab,需要隐藏掉某些tab。使用removeTab()固然可以做到,但是这样的话我们再次需要显示这些tab时再把它们加进去,有时候计算index会很麻烦。所以有没有什么办法可以在不删除tab的前提下隐藏掉某些tab呢,这样就能避免再次添加tab和计算index的麻烦。 遗憾的是Qt并没有对tab提供类似hide()或者setVis_qt settabenabled

acwing---797---差分(前缀和与差分)_初见。。的博客-程序员宅基地

797---差分题目思路题解题目思路板子题,一维差分公式题解#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int N=1e5+10;int n,m;int a[N],b[N];void insert(int l,int r,int c){ b[l]+=c; b[r+1]-=c;}int main()

Ubuntu make-程序员宅基地

Ubuntu 安装makemake工具相当于一个智能的批处理工具,本身没有编译和链接的功能,而是用类似于批处理的方式通过调用makefile文件中用户指定的命令来进行编译和链接。而makefile又是什么,就相当于用户将要执行的一系列命令,make根据makefile中的命令对相应的源文件进行编译和链接的。方法一:(自动安装)1、进入root权限:su root2、更新安装列表:a..._ubuntu make

QImage 总结_qimage函数-程序员宅基地

图像的数据是以字节为单位保存的,每一行的字节数必须是4的整数倍,不足的补0。(因为我们使用的是32操作系统,因此数据是按照32位对齐的,所以每行的字节数必须是4的整数倍也就是说每行的数据位必须是32位的整数倍。)这里是按照我的理解的,貌似错了,修正一下,最近在看数据对齐,这段话先忽略了,没有删掉,是因为,想留个足迹,等我找到合适的答案再贴上来。不过,图像的数据确实是按32位对齐的。如果不是_qimage函数

从mysql导出csv数据 并再将csv导入oracle-程序员宅基地

mysql -uroot -ppasswordSELECT * FROM TABLE INTO OUTFILE 'c://a.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';将csv文件另存为ANSI格式的文件sqlldr us

FreeRTOS:卡在configASSERT( ( pxQueue ) )问题的解决-程序员宅基地

FreeRTOS卡在configASSERT( ( pxQueue ) )问题的解决_configassert