初中生
最后登录1970-1-1
在线时间 小时
注册时间2024-11-22
|
我已经完成了Qt源码的交叉编译,但在用Qt Creator构建时,出现了如下错误:
- /home/lucasyuen/qt/qt6Host/libexec/uic ../../mainwindow.ui -o ui_mainwindow.h
- 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
- 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
- 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
- /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
- In file included from /usr/arm-linux-gnueabihf/include/features.h:510,
- from /usr/arm-linux-gnueabihf/include/c++/11/arm-linux-gnueabihf/bits/os_defines.h:39,
- from /usr/arm-linux-gnueabihf/include/c++/11/arm-linux-gnueabihf/bits/c++config.h:586,
- from /usr/arm-linux-gnueabihf/include/c++/11/type_traits:38,
- from ../../../../sysroot/opt/prefix/include/QtCore/qglobal.h:13,
- from ../../../../sysroot/opt/prefix/include/QtGui/qtguiglobal.h:7,
- from ../../../../sysroot/opt/prefix/include/QtWidgets/qtwidgetsglobal.h:7,
- from ../../../../sysroot/opt/prefix/include/QtWidgets/qmainwindow.h:7,
- from ../../../../sysroot/opt/prefix/include/QtWidgets/QMainWindow:1,
- from ../../mainwindow.h:4,
- from ../../main.cpp:1:
- /usr/arm-linux-gnueabihf/include/gnu/stubs.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory
- 7 | # include <gnu/stubs-soft.h>
- | ^~~~~~~~~~~~~~~~~~
- In file included from /usr/arm-linux-gnueabihf/include/features.h:510,
- from /usr/arm-linux-gnueabihf/include/c++/11/arm-linux-gnueabihf/bits/os_defines.h:39,
- from /usr/arm-linux-gnueabihf/include/c++/11/arm-linux-gnueabihf/bits/c++config.h:586,
- from /usr/arm-linux-gnueabihf/include/c++/11/type_traits:38,
- from ../../../../sysroot/opt/prefix/include/QtCore/qglobal.h:13,
- from ../../../../sysroot/opt/prefix/include/QtGui/qtguiglobal.h:7,
- from ../../../../sysroot/opt/prefix/include/QtWidgets/qtwidgetsglobal.h:7,
- from ../../../../sysroot/opt/prefix/include/QtWidgets/qmainwindow.h:7,
- from ../../../../sysroot/opt/prefix/include/QtWidgets/QMainWindow:1,
- from ../../mainwindow.h:4,
- from ../../mainwindow.cpp:1:
- /usr/arm-linux-gnueabihf/include/gnu/stubs.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory
- 7 | # include <gnu/stubs-soft.h>
- | ^~~~~~~~~~~~~~~~~~
- compilation terminated.
- compilation terminated.
- make: *** [Makefile:1645: main.o] Error 1
- make: *** Waiting for unfinished jobs....
- make: *** [Makefile:1913: mainwindow.o] Error 1
- 17:32:45: 进程"/usr/bin/make"退出,退出代码 2 。
- Error while building/deploying project untitled (kit: zynq_qt)
- The kit zynq_qt has configuration issues which might be the root cause for this problem.
- When executing step "Make"
复制代码 致命错误是没有stubs-soft.h文件,我检查了我当前系统中的报错路径下的文件,的确是没有,有的是stubs-hard.h。
虽然我明白这是根据宏定义来实现选择:
- #if !defined __ARM_PCS_VFP
- # include <gnu/stubs-soft.h>
- #endif
- #if defined __ARM_PCS_VFP
- # include <gnu/stubs-hard.h>
- #endif
复制代码 并且,我查阅了大量资料,说是在toolchain.cmake和qmake.conf中对编译器标志添加-march=armv7-a -marm -mfpu=vfp -mfloat-abi=hard,我的确是这么做了,并且变体这两个文件很多次,可始终都会报错。我不清楚是不是我的这两个文件哪里有问题,所以我贴在那里,希望有大佬能指点一下:
toolchain.cmake
- # 设置 CMake 支持的最小版本
- cmake_minimum_required(VERSION 3.18)
- include_guard(GLOBAL)
- # 设置目标系统为 Linux 和目标架构为 ARM
- set(CMAKE_SYSTEM_NAME Linux)
- set(CMAKE_SYSTEM_PROCESSOR arm)
- # 指定 sysroot 目录
- set(TARGET_SYSROOT /home/lucasyuen/sysroot)
- # 指定交叉编译工具链路径
- #set(CROSS_COMPILER /usr/bin/arm-linux-gnueabihf)
- # 设置 CMake 的 sysroot
- set(CMAKE_SYSROOT ${TARGET_SYSROOT})
- # 设置编译器
- set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc)
- set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++)
- # 设置体系结构
- set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf)
- # 为 C 编译器设置标志
- 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")
- # 为 C++ 编译器设置标志
- 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")
- # 设置 pkg-config 环境变量以定位库和头文件
- set(ENV{PKG_CONFIG_PATH} "${TARGET_SYSROOT}/usr/lib/pkgconfig:${TARGET_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${TARGET_SYSROOT}/usr/share/pkgconfig/")
- set(ENV{PKG_CONFIG_LIBDIR} "${TARGET_SYSROOT}/usr/lib/pkgconfig:${TARGET_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${TARGET_SYSROOT}/usr/share/pkgconfig/")
- set(ENV{PKG_CONFIG_SYSROOT_DIR} "${CMAKE_SYSROOT}")
- # 配置查找路径模式
- set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
- set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
- set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
- set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
- set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
- # 指定 Qt 编译和链接选项(如果需要用到 Qt)
- set(QT_COMPILER_FLAGS "-march=armv7-a -marm -mfpu=vfp -mfloat-abi=hard")
- set(QT_COMPILER_FLAGS_RELEASE "-O2 -pipe")
- set(QT_LINKER_FLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-fuse-ld=gold -ldbus-1")
- # 初始化编译器和链接器标志
- include(CMakeInitializeConfigs)
- function(cmake_initialize_per_config_variable _PREFIX _DOCSTRING)
- if (_PREFIX MATCHES "CMAKE_(C|CXX|ASM)_FLAGS")
- set(CMAKE_${CMAKE_MATCH_1}_FLAGS_INIT "${QT_COMPILER_FLAGS}")
- foreach (config DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
- if (DEFINED QT_COMPILER_FLAGS_${config})
- set(CMAKE_${CMAKE_MATCH_1}_FLAGS_${config}_INIT "${QT_COMPILER_FLAGS_${config}}")
- endif()
- endforeach()
- endif()
- if (_PREFIX MATCHES "CMAKE_(SHARED|MODULE|EXE)_LINKER_FLAGS")
- foreach (config SHARED MODULE EXE)
- set(CMAKE_${config}_LINKER_FLAGS_INIT "${QT_LINKER_FLAGS}")
- endforeach()
- endif()
- _cmake_initialize_per_config_variable(${ARGV})
- endfunction()
复制代码 qmake.conf
- #
- # Generic qmake configuration for building with g++ on arm devices.
- #
- # A minimal configure line could look something like this:
- # ./configure -device arm-generic-g++ -device-option CROSS_COMPILE=arm-linux-gnueabi-
- include(../common/linux_device_pre.conf)
- # 设置OpenGL和EGL库
- QMAKE_LIBS_EGL += -lEGL -lmali
- QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL -lmali
- # 设置编译选项
- QT_QPA_DEFAULT_PLATFORM = xcb
- QMAKE_CFLAGS = -O2 -march=armv7-a -mfpu=vfp -mfloat-abi=hard
- QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
- # 链接器选项
- QMAKE_LFLAGS += -static-libstdc++
- # 设置包含目录(Include Directories)
- QMAKE_INCDIR_POST += $$[QT_SYSROOT]/usr/include $$[QT_SYSROOT]/usr/include/arm-linux-gnueabihf/
- # 设置库目录(Library Directories)
- QMAKE_LIBDIR_POST += $$[QT_SYSROOT]/usr/lib $$[QT_SYSROOT]/lib/$${GCC_MACHINE_DUMP} $$[QT_SYSROOT]/usr/lib/$${GCC_MACHINE_DUMP}
- # 设置 RPATH 链接目录(Runtime Library Search Path)
- QMAKE_RPATHLINKDIR_POST += $$[QT_SYSROOT]/usr/lib $$[QT_SYSROOT]/usr/lib/$${GCC_MACHINE_DUMP} $$[QT_SYSROOT]/lib/$${GCC_MACHINE_DUMP}
- # 编译器配置,明确指定交叉编译工具链
- QMAKE_CC = arm-linux-gnueabihf-gcc
- QMAKE_CXX = arm-linux-gnueabihf-g++
- QMAKE_LINK = arm-linux-gnueabihf-g++
- QMAKE_LINK_SHLIB = arm-linux-gnueabihf-g++
- # 工具链配置
- QMAKE_AR = arm-linux-gnueabihf-ar cqs
- QMAKE_OBJCOPY = arm-linux-gnueabihf-objcopy
- QMAKE_NM = arm-linux-gnueabihf-nm -P
- QMAKE_STRIP = arm-linux-gnueabihf-strip
- # 设置交叉编译目标选项
- DISTRO_OPTS += armv7
- DISTRO_OPTS += deb-multi-arch
- include(../common/linux_arm_device_post.conf)
- load(qt_config)
复制代码
|
|