如何使用 Raspbian 准备 Raspberry Pi,以便我可以从 Linux 主机交叉编译 Qt5 程序? [英] How do I prepare a Raspberry Pi with Raspbian so I can cross compile Qt5 programs from a Linux host?

查看:10
本文介绍了如何使用 Raspbian 准备 Raspberry Pi,以便我可以从 Linux 主机交叉编译 Qt5 程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Linux 上为 Raspberry Pi 1 设置一个交叉编译环境.特别是我想尝试前沿版本,即 Raspbian 测试 + Qt5 开发分支.

I want to setup a cross compile environment on Linux for the Raspberry Pi 1. Especially I want to try bleeding edge version, i.e. Raspbian testing + Qt5 dev branch.

这个问题:如何创建Raspberry Pi 1 的现代交叉编译工具链?

...解释了如何获得 gcc 编译器,它可以为 Raspberry Pi 1 创建代码.是否需要对 Raspbian 本身进行更改才能使用它?如果有,是哪些?

...explains how to get a gcc compiler, which can create code for the Raspberry Pi 1. Are there changes necessary on Raspbian itself to use it? If so, which ones?

推荐答案

安装最前沿的开发系统/工具链有点问题...它是一个不断变化的目标.以下步骤在 2015 年 3 月对我有用.如果他们仍然 100% 工作或他们将工作多长时间......但是如果你已经阅读并理解了以下walktrough",那么为未来的 Raspian 或Qt5 版本.

Installing a bleeding edge development system/toolchain is a bit of a problem... It is a moving target. The following steps did work for me March 2015. If they still 100% work or how long they will work... But if one have read and understood the following 'walktrough' it should not be difficult to adjust the process for future Raspian or Qt5 versions.

第一步应该是更新 Raspian.我升级到测试.为此,请将/etc/apt/sources.list 中的存储库更改为:

Fist step should be to update Raspian. I upgraded to testing. To do this, change the repository in /etc/apt/sources.list to:

deb http://mirrordirector.raspbian.org/raspbian/ 测试主要贡献非自由rpi

deb http://mirrordirector.raspbian.org/raspbian/ testing main contrib non-free rpi

接着是通常的apt-get update、apt-get upgrade、apt-get dist-upgrade".或模拟 aptitude 命令.在这一步之后,已经升级到最新的 Raspian.具有测试版本的所有风险和好处.

Followed by the usual 'apt-get update, apt-get upgrade, apt-get dist-upgrade'. Or an analogue aptitude command. After this step one has upgraded to the most recent Raspian. With all the risks and benefits of a testing release.

接下来需要安装几个包.可能不是所有必要的,例如xcb 在 RPi 上不起作用,并且 RPi 有自己的一组 opengl 文件.但是一些 Raspian 包不知道这一点,并且可能会以任何方式将它们拉进来.下面的包允许使用 QMultimedia 和

Next a couple of packages needs to be installed. Probably not all necessary, e.g. xcb does not work on a RPi, and the RPi hat its own set of opengl files. But some Raspian packages don't know this and might pull them in anyways. The packages below allow to compile a Qt5 with QMultimedia and

apt-get install -y "^libxcb.*" libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libicu-dev libxslt1-dev 
apt-get install -y libssl-dev libxcursor-dev libxrandr-dev libfontconfig1-dev libcap-dev libbz2-dev libgcrypt11-dev 
apt-get install -y libpci-dev libnss3-dev libxtst-dev libasound2-dev libcups2-dev libpulse-dev libudev-dev 
apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libproxy-dev libmtdev-dev libts-dev  
apt-get install -y libxkbcommon-x11-dev libxkbcommon-dev libinput-dev libgbm-dev libjpeg8-dev  libgif-dev libopenjpeg-dev 
apt-get install -y libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev sqlite3 libsqlite3-dev libwayland-dev 
apt-get install -y libdirectfb-dev libegl1-mesa-dev  libsystemd-journal-dev libharfbuzz-dev xutils-dev libcairo2-dev
apt-get install -y libffi-dev libpam0g-dev

下一步也是最重要的一步,也是最不愉快的一步.Raspian 中的几个库是具有绝对路径的符号链接.这很糟糕,因为稍后在编译 Qt5 时找不到这些库.相关库的所有符号链接必须转换为具有相对路径的符号链接.在谷歌的帮助下,可以找到一个脚本,它几乎是自动完成的,但由于某种原因它对我不起作用.因此我是手动完成的.如果我必须更频繁地这样做,我当然会自己写.这也是最容易断的一步.库版本改变...所以不要盲目复制/粘贴下面的命令.

The next and most important step is also the most unpleasant one. A couple of libraries in Raspian are symbolic links with absolute paths. This is bad since those libraries are later on not found when Qt5 is compiled. All symlinks of relevant libs must be turned into symlinks with relative paths. With Google's help a script can be found, which did this almost automatically, but for some reason it did not work for me. Therefore I did it manually. If I have to do this more often, I certainly will write my own. This is also the step, which is most likely to break. Library versions change... so don't blindly copy/paste the commands below.

并非下面的所有库都是编译 Qt5 所必需的,但它们最终都可能成为问题.在这一步之后,Raspberry Pi 就可以使用了.下一步就是编译安装Qt5.

Not all of the libs below are necessary to compile Qt5, but all of them could be a problem eventually. After this step the Raspberry Pi is ready to be used. Next step is to compile and install Qt5.

编写这样一个迷你教程的副作用之一:人们再次思考自己做过的某些事情.有一种更简单的方法可以将绝对链接转换为相对链接:符号链接.

One of the side effects of writing such a mini-tutorial: One thinks again about certain things one has done. There is a much easier way to convert absolute links into relative links: symlinks.

所以:

apt-get 安装符号链接

apt-get install symlinks

然后在树莓派上的/usr/lib/中:

And then in /usr/lib/ on the Raspberry Pi:

符号链接 -cr .

这篇关于如何使用 Raspbian 准备 Raspberry Pi,以便我可以从 Linux 主机交叉编译 Qt5 程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆