树莓派交叉编译知识

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:
    • rsync -rl pi@raspberrypi.bigpond:/lib .
    • rsync -rl pi@raspberrypi.bigpond:/usr .

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:
    • rsync -rl pi@raspberrypi.bigpond:/lib .
    • rsync -rl pi@raspberrypi.bigpond:/usr .

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版本并使用多体系结构功能。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值