交叉编译树莓派QT5.10

交叉编译树莓派QT5.10

环境准备

挂载镜像

挂载镜像更稳健系统到 /mnt

$ unzip 2017-11-29-raspbian-stretch.zip
Archive:  2017-11-29-raspbian-stretch.zip
  inflating: 2017-11-29-raspbian-stretch.img

$ sudo fdisk -l 2017-11-29-raspbian-stretch.img
[sudo] password for wind:

Disk 2017-11-29-raspbian-stretch.img: 4919 MB, 4919918592 bytes
255 heads, 63 sectors/track, 598 cylinders, total 9609216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x49783f5b

                          Device Boot      Start         End      Blocks   Id  System
2017-11-29-raspbian-stretch.img1            8192       93236       42522+   c  W95 FAT32 (LBA)
2017-11-29-raspbian-stretch.img2           94208     9609215     4757504   83  Linux

### offset = 94208 * 512 = 48234496
$ sudo mount -o loop,offset=48234496 2017-11-29-raspbian-stretch.img /mnt
$ cd /mnt
ROOTFS=/mnt
TOOLCHAIN=/path/to/gcc-linaro-4.9-2015.02-3-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-

配置

$ tar -xJvf qt-everywhere-src-5.10.0.tar.xz
$ cd qt-everywhere-src-5.10.0
$ ./configure -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=/home/wind/opt/raspi/tools/arm-bcm2708/gcc-linaro-4.9-2015.02-3-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /mnt -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt5
### add -make tools -make examples options if need

此时出下面的错误

ERROR: Cannot compile a minimal program. The toolchain or QMakeSpec is broken.
ERROR: The OpenGL functionality tests failed! You might need to modify the include and library search paths
by editing QMAKE_INCDIR_OPENGL[_ES2], QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in t
树莓派进行 Qt5.12 交叉编译可按以下详细步骤操作: ### 环境准备 - **系统**:可使用 Ubuntu 系统,如 Ubuntu 18.04 等。 - **Qt 源码**:获取 Qt5.12 源码,可从 Qt 官方网站下载 `qt-everywhere-src-5.12.x.tar.xz` 压缩包。 - **交叉编译工具**:根据树莓派的架构选择合适的交叉编译工具链,例如 `gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf` 等。 ### 安装交叉编译工具链 将下载好的交叉编译工具链解压到指定目录,如 `/opt/cross-compiler`,并将其 bin 目录添加到系统环境变量 `PATH` 中: ```bash export PATH=/opt/cross-compiler/bin:$PATH ``` ### 配置树莓派根文件系统 挂载树莓派的 SD 卡到 Ubuntu 系统上,一般挂载到 `/mnt/raspberrypi` 目录。 ```bash sudo mkdir /mnt/raspberrypi sudo mount /dev/sdX1 /mnt/raspberrypi ``` 这里 `/dev/sdX1` 是树莓派 SD 卡的分区,根据实际情况修改。 ### 配置 Qt 编译选项 创建一个配置脚本,例如 `configure-rpi-qt5.12.sh`,内容如下: ```bash #!/bin/bash ./configure \ -release \ -opengl es2 \ -device linux-rasp-pi3-g++ \ -device-option CROSS_COMPILE=arm-linux-gnueabihf- \ -sysroot /mnt/raspberrypi \ -opensource \ -confirm-license \ -make libs \ -prefix /usr/local/qt5.12 \ -extprefix /home/user/qt5.12-rpi \ -hostprefix /home/user/qt5.12-host \ -v ``` 其中,`-device` 选项根据树莓派型号选择合适的设备配置;`-sysroot` 指向树莓派根文件系统挂载目录;`-prefix` 是安装到树莓派的路径;`-extprefix` 是编译后文件的输出路径;`-hostprefix` 是主机上的安装路径。 ### 编译和安装 Qt 运行配置脚本: ```bash chmod +x configure-rpi-qt5.12.sh ./configure-rpi-qt5.12.sh ``` 配置完成后,开始编译: ```bash make -j$(nproc) ``` 编译完成后,进行安装: ```bash make install ``` ### 部署到树莓派 将编译好的 Qt 库复制到树莓派: ```bash rsync -avz /home/user/qt5.12-rpi/ pi@<树莓派 IP 地址>:/usr/local/qt5.12 ``` ### 设置环境变量 在树莓派上编辑 `/etc/profile` 文件,添加以下内容: ```bash export LD_LIBRARY_PATH=/usr/local/qt5.12/lib:$LD_LIBRARY_PATH export PATH=/usr/local/qt5.12/bin:$PATH ``` 使环境变量生效: ```bash source /etc/profile ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值