我正在尝试为树莓派计算模块交叉编译最新的 Qt(5.9 版)。我对此很陌生,但发现本指南非常有帮助:https://visualgdb.com/tutorials/raspberry/qt/embedded/
我按照说明进行操作,但是在配置 qt 时,我有指南中建议的以下命令(我已将 5.5 版替换为 5.9 版):
../qt-everywhere-opensource-src-5.9.0/configure -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -release -opengl es2 -device linux-rasp-pi2-g++ -sysroot C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -prefix/usr/local/qt5
在我的例子中,这引发了我无法同时指定 xplatform
和 device
参数的错误。我是新手,我不确定应该指定两者中的哪一个!
最佳答案
当您选择 mkspec 进行配置时,您可以使用 -platform
选择主机平台,或者在交叉编译时,您可以使用 -xplatform< 选择目标平台
。为特定支持 设备进行交叉编译时,您选择带有-device
的mkspec。您可以使用 -device-option
标志为特定设备提供选项。使用 -device
标志时,您不使用 -xplatform
标志。
在 Qt 中,似乎有一个用于 Raspberry Pi 2 的设备 mkspec。您可以从 Qt 源代码树的 qtbase 模块中找到 Qt mkspecs,例如树莓派 2 mkspec:qt-everywhere-opensource-src-5.9.0/qtbase/mkspecs/devices/linux-rasp-pi2-g++
。
有Raspberry Pi Beginners Guide在 Qt wiki 中,这可能会有所帮助。它说你应该首先构建qtbase,然后一个一个地编译其他模块。在 wiki 中有一个使用 -device
和 -device-option
标志的 Raspberry Pi 2(在 Linux 主机环境中)的示例配置命令:
./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /mnt/rasp-pi-rootfs -opensource -confirm-license -optimized-qmake -reduce-exports -release -make libs -prefix /usr/local/qt5pi -hostprefix /usr/local/qt5pi
make -j 4
sudo make install
关于qt 配置交叉编译问题 : device and xplatform,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44529558/