无法识别的命令行选项“-mfloat-abi=softfp” | Raspberry Pi 4 的 Qt 交叉编译 | Debian 11 aarch64

unrecognized command-line option "-mfloat-abi=softfp" | Qt Cross Compilation for Raspberry Pi 4 | Debian 11 aarch64

我已经从这个页面安装了 Debian Bullseye: https://raspi.debian.net/daily-images/

在 Raspberry Pi 4 机器上并按照这些指南准备所需的库和包:

https://www.interelectronix.com/qt-515-cross-compilation-raspberry-compute-module-4-ubuntu-20-lts.html

https://github.com/abhiTronix/raspberry-pi-cross-compilers/blob/master/QT_build_instructions.md

这是我正在使用的编译器:https://snapshots.linaro.org/gnu-toolchain/12.0-2021.10-1/aarch64-linux-gnu/gcc-linaro-12.0.0-2021.10-x86_64_aarch64-linux-gnu.tar.xz

来自此页面:https://snapshots.linaro.org/gnu-toolchain/12.0-2021.10-1/aarch64-linux-gnu/


问题描述

当我 运行 ./configure... 经过一些处理后,编译器抛出错误:

aarch64-linux-gnu-g++: error: unrecognized command-line option -mfloat-abi=softfp

同时,Linaro 或官方 ARM 编译器不支持 VFP、FPU 等,因此我不得不更改 qmake.conf 以尝试从编译器标志中删除该命令行选项。

QMAKE_CFLAGS -= -mfloat-abi=softfp
QMAKE_CFLAGS_RELEASE -= -mfloat-abi=softfp
QMAKE_CXXFLAGS -= -mfloat-abi=softfp
QMAKE_CXXFLAGS_RELEASE -= -mfloat-abi=softfp

我已经尝试了以下列出的所有解决方案:Qmake: how to remove compiler flag for a certain project, without changing qmake.conf?

但是还是没有运气!该命令行又神奇地出现了!

你为 aarch64 编译成功了吗?

我该如何解决这个问题?

更新

我的配置命令:

~/Qt/5.15.2/Src/configure -release -device linux-rasp-pi4-v3d-g++ \
-device-option CROSS_COMPILE=~/Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/tools/gcc-linaro-12.0.0-2021.10-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- \
-sysroot ~/Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/sysroot -prefix /usr/local/qt5.15.2 \
-extprefix ~/Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/qt5.15.2 \
-opensource -confirm-license -skip qtscript -skip qtwayland -skip qtwebengine \
-nomake tests -make libs -pkg-config -no-use-gold-linker -v -recheck \
-L~/Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/sysroot/usr/lib/aarch64-linux-gnu \
-I~/Documents/Qt-CrossCompile-RaspberryPi/raspberrypi4/sysroot/usr/include/aarch64-linux-gnu

我在 linux-rasp-pi4-v3d-g++ 文件夹中编辑了 qmake.conf:

include(../common/linux_device_pre.conf)

#QMAKE_LIBS_EGL         += -lEGL
#QMAKE_LIBS_OPENGL_ES2  += -lGLESv2 -lEGL

#QMAKE_CFLAGS            = -march=armv8-a -mtune=cortex-a72 -mfpu=crypto-neon-fp-armv8
QMAKE_CFLAGS            = -march=armv8-a -mtune=cortex-a72
QMAKE_CXXFLAGS          = $$QMAKE_CFLAGS

#DISTRO_OPTS            += hard-float
DISTRO_OPTS            += deb-multi-arch

#EGLFS_DEVICE_INTEGRATION = eglfs_kms

include(../common/linux_arm_device_post.conf)

QMAKE_CFLAGS            = $$replace(QMAKE_CFLAGS, "-mfloat-abi=softfp", "")
QMAKE_CFLAGS_RELEASE            = $$replace(QMAKE_CFLAGS_RELEASE, "-mfloat-abi=softfp", "")
QMAKE_CXXFLAGS          = $$replace(QMAKE_CXXFLAGS, "-mfloat-abi=softfp", "")
QMAKE_CXXFLAGS_RELEASE          = $$replace(QMAKE_CXXFLAGS_RELEASE, "-mfloat-abi=softfp", "")

COMPILER_FLAGS            = $$replace(COMPILER_FLAGS, "-mfloat-abi=softfp", "")

load(qt_config)

通过编辑 qmake.conf

解决了这个问题

使用 linux_device_post 而不是 linux_arm_device_post

include(../common/linux_device_pre.conf)
QT_QPA_DEFAULT_PLATFORM =

QMAKE_CFLAGS            = -march=armv8-a -mtune=cortex-a72
QMAKE_CXXFLAGS          = $$QMAKE_CFLAGS

DISTRO_OPTS            += deb-multi-arch

include(../common/linux_device_post.conf)

load(qt_config)