野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 826|回复: 2

[求助] fatal error: gnu/stubs-soft.h: No such file or directory

[复制链接]
发表于 2024-12-4 17:41:25 | 显示全部楼层 |阅读模式
我已经完成了Qt源码的交叉编译,但在用Qt Creator构建时,出现了如下错误:

  1. /home/lucasyuen/qt/qt6Host/libexec/uic ../../mainwindow.ui -o ui_mainwindow.h
  2. arm-linux-gnueabihf-g++ -c -O2 -march=armv7-a -mfpu=vfp -mfloat-abi=hard <b><font color="#ff0000">-mfloat-abi=softfp</font></b> --sysroot=/home/lucasyuen/sysroot -g -std=gnu++1z -Wall -Wextra -D_REENTRANT -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../untitled -I. -I../../../../sysroot/opt/prefix/include -I../../../../sysroot/opt/prefix/include/QtWidgets -I../../../../sysroot/opt/prefix/include/QtGui -I../../../../sysroot/opt/prefix/include/QtCore -I. -I. -I../../../../sysroot/usr/include -I../../../../sysroot/usr/include/arm-linux-gnueabihf -I../../../../sysroot/opt/prefix/mkspecs/devices/linux-zynq-g++ -o main.o ../../main.cpp
  3. arm-linux-gnueabihf-g++ -c -O2 -march=armv7-a -mfpu=vfp -mfloat-abi=hard <b><font color="#ff0000">-mfloat-abi=softfp</font></b> --sysroot=/home/lucasyuen/sysroot -g -std=gnu++1z -Wall -Wextra -D_REENTRANT -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../untitled -I. -I../../../../sysroot/opt/prefix/include -I../../../../sysroot/opt/prefix/include/QtWidgets -I../../../../sysroot/opt/prefix/include/QtGui -I../../../../sysroot/opt/prefix/include/QtCore -I. -I. -I../../../../sysroot/usr/include -I../../../../sysroot/usr/include/arm-linux-gnueabihf -I../../../../sysroot/opt/prefix/mkspecs/devices/linux-zynq-g++ -o mainwindow.o ../../mainwindow.cpp
  4. arm-linux-gnueabihf-g++ -O2 -march=armv7-a -mfpu=vfp -mfloat-abi=hard<font color="#ff0000"><b> -mfloat-abi=softfp</b></font> --sysroot=/home/lucasyuen/sysroot -g -std=gnu++1z -Wall -Wextra -dM -E -o moc_predefs.h ../../../../sysroot/opt/prefix/mkspecs/features/data/dummy.cpp
  5. /home/lucasyuen/qt/qt6Host/libexec/moc -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include /home/lucasyuen/qtprj/untitled/build/zynq_qt-Debug/moc_predefs.h -I/home/lucasyuen/sysroot/opt/prefix/mkspecs/devices/linux-zynq-g++ -I/home/lucasyuen/qtprj/untitled -I/home/lucasyuen/sysroot/opt/prefix/include -I/home/lucasyuen/sysroot/opt/prefix/include/QtWidgets -I/home/lucasyuen/sysroot/opt/prefix/include/QtGui -I/home/lucasyuen/sysroot/opt/prefix/include/QtCore -I. -I/usr/arm-linux-gnueabihf/include/c++/11 -I/usr/arm-linux-gnueabihf/include/c++/11/arm-linux-gnueabihf -I/usr/arm-linux-gnueabihf/include/c++/11/backward -I/usr/lib/gcc-cross/arm-linux-gnueabihf/11/include -I/usr/arm-linux-gnueabihf/include -I/home/lucasyuen/sysroot/usr/include/arm-linux-gnueabihf -I/home/lucasyuen/sysroot/usr/include ../../mainwindow.h -o moc_mainwindow.cpp
  6. In file included from /usr/arm-linux-gnueabihf/include/features.h:510,
  7.                  from /usr/arm-linux-gnueabihf/include/c++/11/arm-linux-gnueabihf/bits/os_defines.h:39,
  8.                  from /usr/arm-linux-gnueabihf/include/c++/11/arm-linux-gnueabihf/bits/c++config.h:586,
  9.                  from /usr/arm-linux-gnueabihf/include/c++/11/type_traits:38,
  10.                  from ../../../../sysroot/opt/prefix/include/QtCore/qglobal.h:13,
  11.                  from ../../../../sysroot/opt/prefix/include/QtGui/qtguiglobal.h:7,
  12.                  from ../../../../sysroot/opt/prefix/include/QtWidgets/qtwidgetsglobal.h:7,
  13.                  from ../../../../sysroot/opt/prefix/include/QtWidgets/qmainwindow.h:7,
  14.                  from ../../../../sysroot/opt/prefix/include/QtWidgets/QMainWindow:1,
  15.                  from ../../mainwindow.h:4,
  16.                  from ../../main.cpp:1:
  17. /usr/arm-linux-gnueabihf/include/gnu/stubs.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory
  18.     7 | # include <gnu/stubs-soft.h>
  19.       |           ^~~~~~~~~~~~~~~~~~
  20. In file included from /usr/arm-linux-gnueabihf/include/features.h:510,
  21.                  from /usr/arm-linux-gnueabihf/include/c++/11/arm-linux-gnueabihf/bits/os_defines.h:39,
  22.                  from /usr/arm-linux-gnueabihf/include/c++/11/arm-linux-gnueabihf/bits/c++config.h:586,
  23.                  from /usr/arm-linux-gnueabihf/include/c++/11/type_traits:38,
  24.                  from ../../../../sysroot/opt/prefix/include/QtCore/qglobal.h:13,
  25.                  from ../../../../sysroot/opt/prefix/include/QtGui/qtguiglobal.h:7,
  26.                  from ../../../../sysroot/opt/prefix/include/QtWidgets/qtwidgetsglobal.h:7,
  27.                  from ../../../../sysroot/opt/prefix/include/QtWidgets/qmainwindow.h:7,
  28.                  from ../../../../sysroot/opt/prefix/include/QtWidgets/QMainWindow:1,
  29.                  from ../../mainwindow.h:4,
  30.                  from ../../mainwindow.cpp:1:
  31. /usr/arm-linux-gnueabihf/include/gnu/stubs.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory
  32.     7 | # include <gnu/stubs-soft.h>
  33.       |           ^~~~~~~~~~~~~~~~~~
  34. compilation terminated.
  35. compilation terminated.
  36. make: *** [Makefile:1645: main.o] Error 1
  37. make: *** Waiting for unfinished jobs....
  38. make: *** [Makefile:1913: mainwindow.o] Error 1
  39. 17:32:45: 进程"/usr/bin/make"退出,退出代码 2 。
  40. Error while building/deploying project untitled (kit: zynq_qt)
  41. The kit zynq_qt has configuration issues which might be the root cause for this problem.
  42. When executing step "Make"
复制代码
致命错误是没有stubs-soft.h文件,我检查了我当前系统中的报错路径下的文件,的确是没有,有的是stubs-hard.h。
虽然我明白这是根据宏定义来实现选择:
  1. #if !defined __ARM_PCS_VFP
  2. # include <gnu/stubs-soft.h>
  3. #endif
  4. #if defined __ARM_PCS_VFP
  5. # include <gnu/stubs-hard.h>
  6. #endif
复制代码
并且,我查阅了大量资料,说是在toolchain.cmake和qmake.conf中对编译器标志添加-march=armv7-a -marm -mfpu=vfp -mfloat-abi=hard,我的确是这么做了,并且变体这两个文件很多次,可始终都会报错。我不清楚是不是我的这两个文件哪里有问题,所以我贴在那里,希望有大佬能指点一下:
toolchain.cmake
  1. # 设置 CMake 支持的最小版本
  2. cmake_minimum_required(VERSION 3.18)
  3. include_guard(GLOBAL)

  4. # 设置目标系统为 Linux 和目标架构为 ARM
  5. set(CMAKE_SYSTEM_NAME Linux)
  6. set(CMAKE_SYSTEM_PROCESSOR arm)

  7. # 指定 sysroot 目录
  8. set(TARGET_SYSROOT /home/lucasyuen/sysroot)

  9. # 指定交叉编译工具链路径
  10. #set(CROSS_COMPILER /usr/bin/arm-linux-gnueabihf)

  11. # 设置 CMake 的 sysroot
  12. set(CMAKE_SYSROOT ${TARGET_SYSROOT})

  13. # 设置编译器
  14. set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc)
  15. set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)

  16. # 设置体系结构
  17. set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf)

  18. # 为 C 编译器设置标志
  19. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${CMAKE_SYSROOT} -fPIC -Wl,-rpath-link,${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE} -Wl,-rpath-link,${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/lib -L${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -I${CMAKE_SYSROOT}/usr/include -I${CMAKE_SYSROOT}/usr/include/${CMAKE_LIBRARY_ARCHITECTURE} -march=armv7-a -marm -mfpu=vfp -mfloat-abi=hard")

  20. # 为 C++ 编译器设置标志
  21. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${CMAKE_SYSROOT} -fPIC -Wl,-rpath-link,${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE} -Wl,-rpath-link,${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/lib -L${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -I${CMAKE_SYSROOT}/usr/include -I${CMAKE_SYSROOT}/usr/include/${CMAKE_LIBRARY_ARCHITECTURE} -march=armv7-a -marm -mfpu=vfp -mfloat-abi=hard")



  22. # 设置 pkg-config 环境变量以定位库和头文件
  23. set(ENV{PKG_CONFIG_PATH} "${TARGET_SYSROOT}/usr/lib/pkgconfig:${TARGET_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${TARGET_SYSROOT}/usr/share/pkgconfig/")
  24. set(ENV{PKG_CONFIG_LIBDIR} "${TARGET_SYSROOT}/usr/lib/pkgconfig:${TARGET_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${TARGET_SYSROOT}/usr/share/pkgconfig/")
  25. set(ENV{PKG_CONFIG_SYSROOT_DIR} "${CMAKE_SYSROOT}")

  26. # 配置查找路径模式
  27. set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
  28. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  29. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  30. set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  31. set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

  32. # 指定 Qt 编译和链接选项(如果需要用到 Qt)
  33. set(QT_COMPILER_FLAGS "-march=armv7-a -marm -mfpu=vfp -mfloat-abi=hard")
  34. set(QT_COMPILER_FLAGS_RELEASE "-O2 -pipe")
  35. set(QT_LINKER_FLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-fuse-ld=gold -ldbus-1")

  36. # 初始化编译器和链接器标志
  37. include(CMakeInitializeConfigs)

  38. function(cmake_initialize_per_config_variable _PREFIX _DOCSTRING)
  39.     if (_PREFIX MATCHES "CMAKE_(C|CXX|ASM)_FLAGS")
  40.         set(CMAKE_${CMAKE_MATCH_1}_FLAGS_INIT "${QT_COMPILER_FLAGS}")

  41.         foreach (config DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
  42.             if (DEFINED QT_COMPILER_FLAGS_${config})
  43.                 set(CMAKE_${CMAKE_MATCH_1}_FLAGS_${config}_INIT "${QT_COMPILER_FLAGS_${config}}")
  44.             endif()
  45.         endforeach()
  46.     endif()

  47.     if (_PREFIX MATCHES "CMAKE_(SHARED|MODULE|EXE)_LINKER_FLAGS")
  48.         foreach (config SHARED MODULE EXE)
  49.             set(CMAKE_${config}_LINKER_FLAGS_INIT "${QT_LINKER_FLAGS}")
  50.         endforeach()
  51.     endif()

  52.     _cmake_initialize_per_config_variable(${ARGV})
  53. endfunction()
复制代码
qmake.conf
  1. #
  2. # Generic qmake configuration for building with g++ on arm devices.
  3. #
  4. # A minimal configure line could look something like this:
  5. # ./configure -device arm-generic-g++ -device-option CROSS_COMPILE=arm-linux-gnueabi-

  6. include(../common/linux_device_pre.conf)

  7. # 设置OpenGL和EGL库
  8. QMAKE_LIBS_EGL         += -lEGL -lmali
  9. QMAKE_LIBS_OPENGL_ES2  += -lGLESv2 -lEGL -lmali

  10. # 设置编译选项
  11. QT_QPA_DEFAULT_PLATFORM = xcb
  12. QMAKE_CFLAGS            = -O2 -march=armv7-a -mfpu=vfp -mfloat-abi=hard
  13. QMAKE_CXXFLAGS          = $$QMAKE_CFLAGS

  14. # 链接器选项
  15. QMAKE_LFLAGS += -static-libstdc++

  16. # 设置包含目录(Include Directories)
  17. QMAKE_INCDIR_POST +=     $$[QT_SYSROOT]/usr/include        $$[QT_SYSROOT]/usr/include/arm-linux-gnueabihf/

  18. # 设置库目录(Library Directories)
  19. QMAKE_LIBDIR_POST +=     $$[QT_SYSROOT]/usr/lib                $$[QT_SYSROOT]/lib/$${GCC_MACHINE_DUMP}                $$[QT_SYSROOT]/usr/lib/$${GCC_MACHINE_DUMP}

  20. # 设置 RPATH 链接目录(Runtime Library Search Path)
  21. QMAKE_RPATHLINKDIR_POST +=     $$[QT_SYSROOT]/usr/lib                $$[QT_SYSROOT]/usr/lib/$${GCC_MACHINE_DUMP}                $$[QT_SYSROOT]/lib/$${GCC_MACHINE_DUMP}

  22. # 编译器配置,明确指定交叉编译工具链
  23. QMAKE_CC = arm-linux-gnueabihf-gcc
  24. QMAKE_CXX = arm-linux-gnueabihf-g++
  25. QMAKE_LINK = arm-linux-gnueabihf-g++
  26. QMAKE_LINK_SHLIB = arm-linux-gnueabihf-g++

  27. # 工具链配置
  28. QMAKE_AR = arm-linux-gnueabihf-ar cqs
  29. QMAKE_OBJCOPY = arm-linux-gnueabihf-objcopy
  30. QMAKE_NM = arm-linux-gnueabihf-nm -P
  31. QMAKE_STRIP = arm-linux-gnueabihf-strip

  32. # 设置交叉编译目标选项
  33. DISTRO_OPTS += armv7
  34. DISTRO_OPTS += deb-multi-arch

  35. include(../common/linux_arm_device_post.conf)
  36. load(qt_config)
复制代码



回复

使用道具 举报

 楼主| 发表于 2024-12-4 17:43:02 | 显示全部楼层
我不清楚的是,明明我没有设置-mfloat-abi=softfp,为什么在构建的报错信息中仍旧存在使用软浮点的选项
回复 支持 反对

举报

 楼主| 发表于 2024-12-9 17:28:35 | 显示全部楼层
已解决该问题。需要更改qmake.conf
回复 支持 反对

举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2025-4-4 10:01 , Processed in 0.180087 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表