首页 > 解决方案 > 为 Raspberry-Pi 4 交叉编译 Qt5.15 时出错

问题描述

在按照 Raspberry-Pi 4 的本教程构建 Qt5.15.2 之后,并在移动复制到 Raspberry-pi 的文件后,当我想在bin文件夹中运行其中一些文件(例如qmake)时,终端上会出现此错误:

qmake

-bash: /usr/local/bin/qmake: cannot execute binary file: Exec format error

我知道这个错误意味着可执行文件(在本例中为qmake可执行文件)无法在此架构中运行,并且在构建步骤中发生了一些错误配置,但我找不到问题。生成的二进制文件能够在主机 machin ( Linux debian 5.10.0-9-amd64 #1 SMP Debian 5.10.70-1 (2021-09-30) x86_64 GNU/Linux ) 上运行,我认为这也不应该发生。

host我已经使用相同的 g++ 编译器测试了简单的 C++ Hello-world 交叉rpi编译,它工作得很好(我的意思是我能够在 rpi 但不能在主机上运行它)

Qt 配置脚本:

home/ahmad/Documents/qt5-source/qt-everywhere-src-5.15.2/configure -release -opengl es2  -eglfs -device linux-rasp-pi4-v3d-g++ -device-option CROSS_COMPILE=~/Documents/projects/avapardaz/raspberry/tools/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot ~/Documents/projects/avapardaz/raspberry/sysroot -prefix /usr/local/qt5.15 -extprefix /home/extra/qt5.15-out -opensource -confirm-license -skip qtscript -skip qtwayland -skip qtwebengine -skip qtlottie -skip qtmacextras -skip qtsensors -skip qtwinextras -skip qtandroidextras -skip qtcharts -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtquick3d -skip qtwebchannel -nomake tests -make libs -pkg-config -no-use-gold-linker -v -recheck

此脚本验证我能够gmake在输出中运行gmakegmake install并将在构建目录中生成大约 8.5 GB 的文件,在生成目录中生成大约 200 MBinstall directory

你知道我该如何解决这个问题吗?我是交叉编译的新手,我没有找到任何在线搜索结果。

标签: qtcross-compiling

解决方案


推荐阅读