写在前面qt6只能跑在ubuntu22.04上，如果在ubuntu20.04上跑qt5有点困难ubuntu20.04 的原生Qtcreator只支持到4.11.0-2build2,界面有点僵硬
1. 编译异常Note: Disabling X11 Accessibility Bridge: D-Bus or AT-SPI is missing. WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation. Either ensure that llvm-config is in your PATH environment variable, or set LLVM_INSTALL_DIR to the location of your llvm installation. On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution. On macOS, you can use Homebrew's llvm package. On Windows, you must set LLVM_INSTALL_DIR to the installation path. ERROR: Feature 'eglfs' was enabled, but the pre-condition '!config.android && !config.darwin && !config.win32 && !config.wasm && features.egl' failed. ERROR: Feature 'fontconfig' was enabled, but the pre-condition '!config.msvc && features.system-freetype && libs.fontconfig' failed. ERROR: Feature 'tslib' was enabled, but the pre-condition 'libs.tslib' failed. ERROR: Feature 'system-sqlite' was enabled, but the pre-condition 'features.sql-sqlite && libs.sqlite3' failed. done...2. 尝试解决解决编译异常2.1 尝试修复fontconfig辅助文章：Linux系统编译QT5.15.0及串口问题# 在嵌入式主机上安装fontconfig sudo apt-get install libfontconfig1-dev # 在主机上同步lib rsync -avz --rsync-path="sudo rsync" cat@192.168.0.113:/usr/lib ~/WorkSpace/lubanCat/rootFS/usr rsync -avz --rsync-path="sudo rsync" cat@192.168.0.113:/usr/include ~/WorkSpace/lubanCat/rootFS/usr symlinks -rc ~/WorkSpace/lubanCat/rootFS再次编译看是否解决:可以看到fontconfig解决了Note: Disabling X11 Accessibility Bridge: D-Bus or AT-SPI is missing. WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation. Either ensure that llvm-config is in your PATH environment variable, or set LLVM_INSTALL_DIR to the location of your llvm installation. On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution. On macOS, you can use Homebrew's llvm package. On Windows, you must set LLVM_INSTALL_DIR to the installation path. ERROR: Feature 'eglfs' was enabled, but the pre-condition '!config.android && !config.darwin && !config.win32 && !config.wasm && features.egl' failed. ERROR: Feature 'tslib' was enabled, but the pre-condition 'libs.tslib' failed. ERROR: Feature 'system-sqlite' was enabled, but the pre-condition 'features.sql-sqlite && libs.sqlite3' failed.2.2 修复其他# 修复OpenGL sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev # 修复tslib sudo apt install libts-dev # 修复system-sqlite sudo apt install -y libsqlite3-dev # 修复eglfs sudo apt install libegl1-mesa-dev libgles2-mesa-dev libgbm-dev libdrm-dev libmtdev-dev # 解决 QDoc 编译警告 sudo apt install -y llvm clang libclang-dev # 解决 X11 无障碍桥警告（信息性） sudo apt install -y libatspi2.0-dev dbus-x11 # 可以直接安装到对应的位置，未尝试，自行 sudo chroot /home/yoooola/WorkSpace/lubanCat/sysroot_debian10 /bin/bash -c "apt install -y libsqlite3-dev"2.3 其他对比文件usr/lib/clang/7/include -> usr/lib/llvm-7/lib/clang/7.0.1/include usr/lib/clang/7/lib -> usr/lib/llvm-7/lib/clang/7.0.1/lib usr/lib/clang/7.0.1/include -> usr/lib/llvm-7/lib/clang/7.0.1/include usr/lib/clang/7.0.1/lib -> usr/lib/llvm-7/lib/clang/7.0.1/lib usr/lib/gcc/aarch64-linux-gnu/8/libobjc.so -> usr/lib/aarch64-linux-gnu/libobjc.so.4.0.0 usr/lib/gcc/aarch64-linux-gnu/8/libgcc_s.so -> lib/aarch64-linux-gnu/libgcc_s.so.1 usr/lib/gcc/aarch64-linux-gnu/8/libgfortran.so -> usr/lib/aarch64-linux-gnu/libgfortran.so.5.0.0 usr/lib/aarch64-linux-gnu/libxml2.so -> usr/lib/aarch64-linux-gnu/libxml2.so.2.9.4 usr/lib/aarch64-linux-gnu/libgettextlib.so -> usr/lib/aarch64-linux-gnu/libgettextlib-0.19.8.1.so usr/lib/aarch64-linux-gnu/libmemtailor.so.0 -> usr/lib/aarch64-linux-gnu/libmemtailor.so.0.0.0 usr/lib/aarch64-linux-gnu/libuv.so.1 -> usr/lib/aarch64-linux-gnu/libuv.so.1.0.0 usr/lib/aarch64-linux-gnu/libcairo-gobject.so -> usr/lib/aarch64-linux-gnu/libcairo-gobject.so.2.11600.0 usr/lib/aarch64-linux-gnu/libpanel.so -> usr/lib/aarch64-linux-gnu/libpanel.so.6.1 usr/lib/aarch64-linux-gnu/libdbus-1.so -> lib/aarch64-linux-gnu/libdbus-1.so.3.19.15 usr/lib/aarch64-linux-gnu/libexpatw.so -> usr/lib/aarch64-linux-gnu/libexpatw.so.1.6.8 usr/lib/aarch64-linux-gnu/libQt5Concurrent.so.5 -> usr/lib/aarch64-linux-gnu/libQt5Concurrent.so.5.11.3 usr/lib/aarch64-linux-gnu/libharfbuzz-gobject.so -> usr/lib/aarch64-linux-gnu/libharfbuzz-gobject.so.0.20301.0 usr/lib/aarch64-linux-gnu/libQt5Sql.so.5.11 -> usr/lib/aarch64-linux-gnu/libQt5Sql.so.5.11.3 usr/lib/aarch64-linux-gnu/libpangoxft-1.0.so -> usr/lib/aarch64-linux-gnu/libpangoxft-1.0.so.0.4200.3 usr/lib/aarch64-linux-gnu/libcairo-script-interpreter.so.2 -> usr/lib/aarch64-linux-gnu/libcairo-script-interpreter.so.2.11600.0 usr/lib/aarch64-linux-gnu/libevent_openssl.so -> usr/lib/aarch64-linux-gnu/libevent_openssl-2.1.so.6.0.2 usr/lib/aarch64-linux-gnu/libct.so.4 -> usr/lib/aarch64-linux-gnu/libct.so.4.0.0 usr/lib/aarch64-linux-gnu/libmenuw.so -> usr/lib/aarch64-linux-gnu/libmenuw.so.6.1 usr/lib/aarch64-linux-gnu/libsigc-2.0.so -> usr/lib/aarch64-linux-gnu/libsigc-2.0.so.0.0.0 usr/lib/aarch64-linux-gnu/libpcre2-posix.so.2 -> usr/lib/aarch64-linux-gnu/libpcre2-posix.so.2.0.1 usr/lib/aarch64-linux-gnu/libts.so.0 -> usr/lib/aarch64-linux-gnu/libts.so.0.10.1 usr/lib/aarch64-linux-gnu/libQt5Xml.so.5.11 -> usr/lib/aarch64-linux-gnu/libQt5Xml.so.5.11.3 usr/lib/aarch64-linux-gnu/libevent_extra.so -> usr/lib/aarch64-linux-gnu/libevent_extra-2.1.so.6.0.2 usr/lib/aarch64-linux-gnu/libicuuc.so -> usr/lib/aarch64-linux-gnu/libicuuc.so.63.1 usr/lib/aarch64-linux-gnu/qt5/bin/syncqt.pl -> usr/lib/qt5/bin/syncqt.pl usr/lib/aarch64-linux-gnu/qt5/bin/rcc -> usr/lib/qt5/bin/rcc usr/lib/aarch64-linux-gnu/qt5/bin/qlalr -> usr/lib/qt5/bin/qlalr usr/lib/aarch64-linux-gnu/qt5/bin/moc -> usr/lib/qt5/bin/moc usr/lib/aarch64-linux-gnu/qt5/bin/uic -> usr/lib/qt5/bin/uic usr/lib/aarch64-linux-gnu/qt5/bin/qdbusxml2cpp -> usr/lib/qt5/bin/qdbusxml2cpp usr/lib/aarch64-linux-gnu/qt5/bin/fixqt4headers.pl -> usr/lib/qt5/bin/fixqt4headers.pl usr/lib/aarch64-linux-gnu/qt5/bin/qdbuscpp2xml -> usr/lib/qt5/bin/qdbuscpp2xml usr/lib/aarch64-linux-gnu/qt5/bin/qmake -> usr/lib/aarch64-linux-gnu/libgstreamermm-1.0.so.1 -> usr/lib/aarch64-linux-gnu/libgstreamermm-1.0.so.1.0.0 usr/lib/aarch64-linux-gnu/libICE.so -> usr/lib/aarch64-linux-gnu/libICE.so.6.3.0 usr/lib/aarch64-linux-gnu/libGLU.so -> usr/lib/aarch64-linux-gnu/libGLU.so.1.3.1 usr/lib/aarch64-linux-gnu/libQt5Gui.so -> usr/lib/aarch64-linux-gnu/libQt5Gui.so.5.11.3 usr/lib/aarch64-linux-gnu/libgtkmm-3.0.so -> usr/lib/aarch64-linux-gnu/libgtkmm-3.0.so.1.1.0 usr/lib/aarch64-linux-gnu/libevdev.so -> usr/lib/aarch64-linux-gnu/libevdev.so.2.2.0 usr/lib/aarch64-linux-gnu/libpangocairo-1.0.so -> usr/lib/aarch64-linux-gnu/libpangocairo-1.0.so.0.4200.3 usr/lib/aarch64-linux-gnu/libmenu.so -> usr/lib/aarch64-linux-gnu/libmenu.so.6.1 /usr/include/ncurses.h -> /usr/include/curses.h /usr/include/speechd_types.h -> /usr/include/speech-dispatcher/speechd_types.h /usr/include/speechd_defines.h -> /usr/include/speech-dispatcher/speechd_defines.h /usr/include/libavfilter -> /usr/include/aarch64-linux-gnu/libavfilter /usr/include/libavresample -> /usr/include/aarch64-linux-gnu/libavresample /usr/include/libswresample -> /usr/include/aarch64-linux-gnu/libswresample /usr/include/libavutil -> /usr/include/aarch64-linux-gnu/libavutil /usr/include/ncursesw/ncurses.h -> /usr/include/curses.h /usr/include/ncursesw/etip.h -> /usr/include/etip.h /usr/include/ncursesw/cursesp.h -> /usr/include/cursesp.h /usr/include/ncursesw/cursesm.h -> /usr/include/cursesm.h /usr/include/ncursesw/menu.h -> /usr/include/menu.h /usr/include/ncursesw/cursesf.h -> /usr/include/cursesf.h /usr/include/ncursesw/eti.h -> /usr/include/eti.h /usr/include/ncursesw/unctrl.h -> /usr/include/unctrl.h /usr/include/ncursesw/curses.h -> /usr/include/curses.h /usr/include/ncursesw/tic.h -> /usr/include/tic.h /usr/include/ncursesw/termcap.h -> /usr/include/termcap.h /usr/include/ncursesw/form.h -> /usr/include/form.h /usr/include/ncursesw/cursslk.h -> /usr/include/cursslk.h /usr/include/ncursesw/term_entry.h -> /usr/include/term_entry.h /usr/include/ncursesw/term.h -> /usr/include/term.h /usr/include/ncursesw/ncurses_dll.h -> /usr/include/ncurses_dll.h /usr/include/ncursesw/cursesapp.h -> /usr/include/cursesapp.h /usr/include/ncursesw/panel.h -> /usr/include/panel.h /usr/include/ncursesw/nc_tparm.h -> /usr/include/nc_tparm.h /usr/include/ncursesw/cursesw.h -> /usr/include/cursesw.h /usr/include/libavdevice -> /usr/include/aarch64-linux-gnu/libavdevice /usr/include/clang/7/include -> /usr/lib/llvm-7/lib/clang/7.0.1/include /usr/include/clang/7.0.1/include -> /usr/lib/llvm-7/lib/clang/7.0.1/include /usr/include/libswscale -> /usr/include/aarch64-linux-gnu/libswscale /usr/include/libavcodec -> /usr/include/aarch64-linux-gnu/libavcodec /usr/include/libspeechd.h -> /usr/include/speech-dispatcher/libspeechd.h /usr/include/openssl/openssl -> /usr/include/libpostproc -> /usr/include/aarch64-linux-gnu/libpostproc /usr/include/asm -> /usr/include/aarch64-linux-gnu/asm /usr/include/libspeechd_version.h -> /usr/include/speech-dispatcher/libspeechd_version.h /usr/include/spd_audio_plugin.h -> /usr/include/speech-dispatcher/spd_audio_plugin.h /usr/include/sys/sys -> /usr/include/gnu -> /usr/include/aarch64-linux-gnu/gnu /usr/include/caml -> /usr/lib/ocaml/caml /usr/include/bits -> /usr/include/aarch64-linux-gnu/bits /usr/include/libavformat -> /usr/include/aarch64-linux-gnu/libavformat
一、在 WSL 上安装 Qt5 编译环境（无图形界面方案）精简安装步骤（无 GUI）更新系统并安装基础依赖sudo apt update && sudo apt upgrade -y sudo apt install -y build-essential cmake ninja-build pkg-config安装 Qt5 核心开发包# 安装最小化的 Qt5 开发环境 sudo apt install -y qt5-qmake qtbase5-dev # 可选：安装常用模块（按需选择） sudo apt install -y \ qtdeclarative5-dev \ qttools5-dev \ qtmultimedia5-dev \ qtscript5-dev验证# 检查 qmake 版本 qmake --version # 检查可用模块 qmake -query QT_INSTALL_LIBS输出如下yoooola@xxxxx:~/WorkSpace/lubanCat$ qmake --version QMake version 3.1 Using Qt version 5.12.8 in /usr/lib/x86_64-linux-gnu yoooola@xxxxx:~/WorkSpace/lubanCat$ qmake -query QT_INSTALL_LIBS /usr/lib/x86_64-linux-gnu二、如果需要WSL使用qtcreatorsudo apt-get update # 安装qt5 sudo apt-get install cmake qt5-default qtcreator # 注意，如果提示如下内容，建议换官方源处理 yoooola@xxxxxx:~/WorkSpace/lubanCat/hello_arm/build$ sudo apt-get install cmake qt5-default qtcreator --fix-missing 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 qt5-default 已经是最新版 (5.9.5+dfsg-0ubuntu2.6)。 cmake 已经是最新版 (3.16.3-1ubuntu1.20.04.1)。 有一些软件包无法被安装。如果您用的是 unstable 发行版，这也许是 因为系统无法达到您要求的状态造成的。该版本中可能会有一些您需要的软件 包尚未被创建或是它们已被从新到(Incoming)目录移出。 下列信息可能会对解决问题有所帮助： 下列软件包有未满足的依赖关系： qtcreator : 依赖: qml-module-qtqml-models2 但是它将不会被安装 依赖: qml-module-qtquick-controls (>= 5.5.0~) 但是它将不会被安装 依赖: qml-module-qtquick2 (>= 5.5.0~) 但是它将不会被安装 依赖: qtdeclarative-abi-5-9-5 推荐: clang 但是它将不会被安装 推荐: qmlscene 但是它将不会被安装 推荐: qt5-doc 但是它将不会被安装 推荐: qtcreator-doc 但是它将不会被安装 推荐: qtxmlpatterns5-dev-tools 但是它将不会被安装 推荐: xterm 但是它将不会被安装 或 x-terminal-emulator E: 无法修正错误，因为您要求某些软件包保持现状，就是它们破坏了软件包间的依赖关系。安装MobaXterm,用来激活界面MobaXterm下载地址安装完成后# 打开MobaXterm，输入 qtcreator 可能会出现QT界面中文显示异常的情况，关闭QT，并链接文字到系统sudo ln -s /mnt/c/Windows/Fonts /usr/share/fonts/font三、后台运行qtcreator# 后台运行 qtcreator & # 后台运行，终端关掉也没事 nohup qtcreator >/dev/null 2>&1 & # 关闭后台qtcreator pkill -9 qtcreator
Qt5交叉编译记录前言使用野火交叉编译Qt库(Qt5)进行linux平台的交叉编译qt5.15.2，发现一些问题。具体是指编译时，执行到4.1.2.2 创建sysroot目录发生了一些问题，导致编译检查时发现缺少以下库文件xcbeglfsfontxconfigtslibsystem-sqlite在不同的平台上多次尝试创建sysroot目录，尝试debian10,debian11均无果。最后在该教程中提到的sysroot_debian10.tar.gz部署以后，终于可以正常完成编译。然后就产生了好奇，为什么我自己从机器上实际同步到编译主机的库文件就找不到呢？一、排查思路1. 排查野火给的库文件和从机器上同步的库文件目录的区别按照泰山派的资料导入板载系统镜像【立创·泰山派RK3566开发板】板载系统镜像提取# 创建目录 mkdir -p ~/WorkSpace/rootfs # 从嵌入式机器上导入库文件 sudo rsync -avx root@192.168.50.113:/ ~/WorkSpace/rootfs # 对比lib目录 diff -rq --brief ~/WorkSpace/sysroot/lib ~/WorkSpace/rootfs/lib | grep "Only in /home/yoooola/WorkSpace/sysroot" > missing_lib_files.txt # 对比usr目录 diff -rq --brief ~/WorkSpace/sysroot/usr ~/WorkSpace/rootfs/usr | grep "Only in /home/yoooola/WorkSpace/sysroot" > missing_usr_files.txt1.1 分析对比结果xcb,eglfs,fontconfig,tslib,system-sqlite 关键文件查找结果yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ find sysroot -path '*plugins/platforms/*eglfs*' 2>/dev/null sysroot/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqeglfs.so yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ find rootfs/ -path '*plugins/platforms/*eglfs*' 2>/dev/null rootfs/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqeglfs.so yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ find sysroot -name 'libfontconfig*.so*' 2>/dev/null sysroot/usr/lib/aarch64-linux-gnu/libfontconfig.so sysroot/usr/lib/aarch64-linux-gnu/libfontconfig.so.1 sysroot/usr/lib/aarch64-linux-gnu/libfontconfig.so.1.12.0 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ find rootfs/ -name 'libfontconfig*.so*' 2>/dev/null rootfs/usr/lib/aarch64-linux-gnu/libfontconfig.so.1 rootfs/usr/lib/aarch64-linux-gnu/libfontconfig.so.1.12.0 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ find sysroot -name '*libts*.so*' 2>/dev/null sysroot/usr/lib/gcc/aarch64-linux-gnu/8/libtsan.so sysroot/usr/lib/aarch64-linux-gnu/libts.so.0 sysroot/usr/lib/aarch64-linux-gnu/libtsan.so.0.0.0 sysroot/usr/lib/aarch64-linux-gnu/libtsan.so.0 sysroot/usr/lib/aarch64-linux-gnu/libts.so sysroot/usr/lib/aarch64-linux-gnu/libts.so.0.10.1 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ find rootfs/ -name '*libts*.so*' 2>/dev/null rootfs/usr/lib/gcc/aarch64-linux-gnu/8/libtsan.so rootfs/usr/lib/aarch64-linux-gnu/libtsan.so.0.0.0 rootfs/usr/lib/aarch64-linux-gnu/libtsan.so.0 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ find sysroot -name 'libsqlite3.so*' 2>/dev/null sysroot/usr/lib/aarch64-linux-gnu/libsqlite3.so.0 sysroot/usr/lib/aarch64-linux-gnu/libsqlite3.so sysroot/usr/lib/aarch64-linux-gnu/libsqlite3.so.0.8.6 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ find rootfs/ -name 'libsqlite3.so*' 2>/dev/null rootfs/usr/lib/aarch64-linux-gnu/libsqlite3.so.0 rootfs/usr/lib/aarch64-linux-gnu/libsqlite3.so.0.8.6 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$1.2 如果直接使用从机器上同步的库文件进行编译报错内容如下yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ ./build-qt.sh start configure platform... # # qmake configuration for the LubanCat running Linux for debian10 # include(../common/linux_device_pre.conf) QMAKE_LIBS_EGL += -lEGL -lmali QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL -lmali QMAKE_CFLAGS = -march=armv8-a QMAKE_CXXFLAGS = $$QMAKE_CFLAGS QMAKE_LFLAGS += -static-libstdc++ QMAKE_INCDIR_POST += $$[QT_SYSROOT]/usr/include $$[QT_SYSROOT]/usr/include/$${GCC_MACHINE_DUMP} QMAKE_LIBDIR_POST += $$[QT_SYSROOT]/usr/lib $$[QT_SYSROOT]/lib/$${GCC_MACHINE_DUMP} $$[QT_SYSROOT]/usr/lib/$${GCC_MACHINE_DUMP} QMAKE_RPATHLINKDIR_POST += $$[QT_SYSROOT]/usr/lib $$[QT_SYSROOT]/usr/lib/$${GCC_MACHINE_DUMP} $$[QT_SYSROOT]/lib/$${GCC_MACHINE_DUMP} DISTRO_OPTS += aarch64 DISTRO_OPTS += deb-multi-arch include(../common/linux_arm_device_post.conf) load(qt_config) done... start configure qt-everywhere-src-5.15.8... + cd qtbase + /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/configure -top-level -sysroot /home/yoooola/WorkSpace/rootfs -hostprefix /opt/qt-everywhere-src-5.15.8/host -extprefix /opt/qt-everywhere-src-5.15.8/ext -device linux-lubancat-g++ -device-option CROSS_COMPILE=/opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu- -release -opensource -confirm-license -nomake tests -make libs -opengl es2 -eglfs -xcb -dbus -syslog -sqlite -tslib -fontconfig -pkg-config -skip qtscript -skip qtwebengine -no-use-gold-linker -v -recheck-all Creating qmake... make: Nothing to be done for 'first'. Command line: -sysroot /home/yoooola/WorkSpace/rootfs -hostprefix /opt/qt-everywhere-src-5.15.8/host -extprefix /opt/qt-everywhere-src-5.15.8/ext -device linux-lubancat-g++ -device-option CROSS_COMPILE=/opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu- -release -opensource -confirm-license -nomake tests -make libs -opengl es2 -eglfs -xcb -dbus -syslog -sqlite -tslib -fontconfig -pkg-config -skip qtscript -skip qtwebengine -no-use-gold-linker -v -recheck-all This is the Qt Open Source Edition. You have already accepted the terms of the Open Source license. Running configuration tests... Checking for machine tuple... + /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-g++ -dumpmachine > aarch64-linux-gnu test config.qtbase.tests.machineTuple succeeded Checking for valid makespec... + cd /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/config.tests/verifyspec && /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_CFLAGS += --sysroot=/home/yoooola/WorkSpace/rootfs" "QMAKE_CXXFLAGS += --sysroot=/home/yoooola/WorkSpace/rootfs" "QMAKE_LFLAGS += --sysroot=/home/yoooola/WorkSpace/rootfs" -early "CONFIG += cross_compile" /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/config.tests/verifyspec + cd /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/config.tests/verifyspec && MAKEFLAGS= /usr/bin/make clean && MAKEFLAGS= /usr/bin/make > rm -f verifyspec.o > rm -f *~ core *.core > /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-g++ -c -march=armv8-a --sysroot=/home/yoooola/WorkSpace/rootfs --sysroot=/home/yoooola/WorkSpace/rootfs -O2 -w -fPIC -I/home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/config.tests/verifyspec -I. -I/home/yoooola/WorkSpace/rootfs/usr/include -I/home/yoooola/WorkSpace/rootfs/usr/include/aarch64-linux-gnu -I/home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/mkspecs/devices/linux-lubancat-g++ -o verifyspec.o /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/config.tests/verifyspec/verifyspec.cpp > /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-g++ -static-libstdc++ --sysroot=/home/yoooola/WorkSpace/rootfs --sysroot=/home/yoooola/WorkSpace/rootfs -Wl,-O1 -Wl,-rpath-link,/home/yoooola/WorkSpace/rootfs/usr/lib -Wl,-rpath-link,/home/yoooola/WorkSpace/rootfs/usr/lib/aarch64-linux-gnu -Wl,-rpath-link,/home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu -Wl,-rpath-link,/home/yoooola/WorkSpace/rootfs/usr/lib/aarch64-linux-gnu -Wl,-rpath-link,/home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu -o verifyspec verifyspec.o -L/home/yoooola/WorkSpace/rootfs/usr/lib -L/home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu -L/home/yoooola/WorkSpace/rootfs/usr/lib/aarch64-linux-gnu > /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory > /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find crti.o: No such file or directory > collect2: error: ld returned 1 exit status > make: *** [Makefile:68: verifyspec] Error 1 Note: Also available for Linux: linux-clang linux-icc ERROR: Cannot compile a minimal program. The toolchain or QMakeSpec is broken. done... yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$可以看到，主要的报错内容如下> /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory > /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find crti.o: No such file or directory > collect2: error: ld returned 1 exit status > make: *** [Makefile:68: verifyspec] Error 1这些文件在两个文件夹下的相对位置分析yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ sudo find rootfs/ -name "crt1.o" rootfs/usr/lib/aarch64-linux-gnu/crt1.o yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ sudo find sysroot/ -name "crt1.o" sysroot/usr/lib/aarch64-linux-gnu/crt1.o可以发现，两个文件在两个文件夹下的目录相同，可以说明，并不是文件不存在，而是编译脚本问题。使用野火的官方库文件目录进行对比，看编译环境到底有什么区别start configure platform... # # qmake configuration for the LubanCat running Linux for debian10 # include(../common/linux_device_pre.conf) QMAKE_LIBS_EGL += -lEGL -lmali QMAKE_LIBS_OPENGL_ES2 += -lGLESv2 -lEGL -lmali QMAKE_CFLAGS = -march=armv8-a QMAKE_CXXFLAGS = $$QMAKE_CFLAGS QMAKE_LFLAGS += -static-libstdc++ QMAKE_INCDIR_POST += $$[QT_SYSROOT]/usr/include $$[QT_SYSROOT]/usr/include/$${GCC_MACHINE_DUMP} QMAKE_LIBDIR_POST += $$[QT_SYSROOT]/usr/lib $$[QT_SYSROOT]/lib/$${GCC_MACHINE_DUMP} $$[QT_SYSROOT]/usr/lib/$${GCC_MACHINE_DUMP} QMAKE_RPATHLINKDIR_POST += $$[QT_SYSROOT]/usr/lib $$[QT_SYSROOT]/usr/lib/$${GCC_MACHINE_DUMP} $$[QT_SYSROOT]/lib/$${GCC_MACHINE_DUMP} DISTRO_OPTS += aarch64 DISTRO_OPTS += deb-multi-arch include(../common/linux_arm_device_post.conf) load(qt_config) done... start configure qt-everywhere-src-5.15.8... + cd qtbase + /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/configure -top-level -sysroot /home/yoooola/WorkSpace/sysroot -hostprefix /opt/qt-everywhere-src-5.15.8/host -extprefix /opt/qt-everywhere-src-5.15.8/ext -device linux-lubancat-g++ -device-option CROSS_COMPILE=/opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu- -release -opensource -confirm-license -nomake tests -make libs -opengl es2 -eglfs -xcb -dbus -syslog -sqlite -tslib -fontconfig -pkg-config -skip qtscript -skip qtwebengine -no-use-gold-linker -v -recheck-all Creating qmake... make: Nothing to be done for 'first'. Command line: -sysroot /home/yoooola/WorkSpace/sysroot -hostprefix /opt/qt-everywhere-src-5.15.8/host -extprefix /opt/qt-everywhere-src-5.15.8/ext -device linux-lubancat-g++ -device-option CROSS_COMPILE=/opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu- -release -opensource -confirm-license -nomake tests -make libs -opengl es2 -eglfs -xcb -dbus -syslog -sqlite -tslib -fontconfig -pkg-config -skip qtscript -skip qtwebengine -no-use-gold-linker -v -recheck-all This is the Qt Open Source Edition. You have already accepted the terms of the Open Source license. Running configuration tests... Checking for machine tuple... + /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-g++ -dumpmachine > aarch64-linux-gnu test config.qtbase.tests.machineTuple succeeded Checking for valid makespec... + cd /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/config.tests/verifyspec && /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_CFLAGS += --sysroot=/home/yoooola/WorkSpace/sysroot" "QMAKE_CXXFLAGS += --sysroot=/home/yoooola/WorkSpace/sysroot" "QMAKE_LFLAGS += --sysroot=/home/yoooola/WorkSpace/sysroot" -early "CONFIG += cross_compile" /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/config.tests/verifyspec + cd /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/config.tests/verifyspec && MAKEFLAGS= /usr/bin/make clean && MAKEFLAGS= /usr/bin/make > rm -f verifyspec.o > rm -f *~ core *.core > /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-g++ -c -march=armv8-a --sysroot=/home/yoooola/WorkSpace/sysroot --sysroot=/home/yoooola/WorkSpace/sysroot -O2 -w -fPIC -I/home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/config.tests/verifyspec -I. -I/home/yoooola/WorkSpace/sysroot/usr/include -I/home/yoooola/WorkSpace/sysroot/usr/include/aarch64-linux-gnu -I/home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/mkspecs/devices/linux-lubancat-g++ -o verifyspec.o /home/yoooola/WorkSpace/qt-everywhere-src-5.15.8/qtbase/config.tests/verifyspec/verifyspec.cpp > /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-g++ -static-libstdc++ --sysroot=/home/yoooola/WorkSpace/sysroot --sysroot=/home/yoooola/WorkSpace/sysroot -Wl,-O1 -Wl,-rpath-link,/home/yoooola/WorkSpace/sysroot/usr/lib -Wl,-rpath-link,/home/yoooola/WorkSpace/sysroot/usr/lib/aarch64-linux-gnu -Wl,-rpath-link,/home/yoooola/WorkSpace/sysroot/lib/aarch64-linux-gnu -Wl,-rpath-link,/home/yoooola/WorkSpace/sysroot/usr/lib/aarch64-linux-gnu -Wl,-rpath-link,/home/yoooola/WorkSpace/sysroot/lib/aarch64-linux-gnu -o verifyspec verifyspec.o -L/home/yoooola/WorkSpace/sysroot/usr/lib -L/home/yoooola/WorkSpace/sysroot/lib/aarch64-linux-gnu -L/home/yoooola/WorkSpace/sysroot/usr/lib/aarch64-linux-gnu test config.qtbase.tests.verifyspec succeeded Checking for target architecture...1.3 一点点小观察从机器获取到的文件的权限是 root root, 不是 yoooola yoooola。尝试从机器重新拷贝文件：# 首先要改变文件的权限 # 我这里直接删除rootfs文件夹，然后重新以非管理员用户创建文件 sudo rm -rf ~/WorkSpace/rootfs mkdir -p ~/WorkSpace/rootfs # 从嵌入式机器上导入库文件,以cat用户读取文件 rsync -avx cat@192.168.50.113:/ ~/WorkSpace/rootfs1.4 再次观察yoooola@HR000000299:~/WorkSpace/lubanCat/rootFS/lib$ ll 总用量 8 drwxr-xr-x 2 yoooola yoooola 4096 7月 22 20:18 ./ drwxr-xr-x 4 yoooola yoooola 4096 7月 22 20:17 ../ lrwxrwxrwx 1 yoooola yoooola 7 7月 1 2024 lib -> usr/lib # 但是这里的链接错了，应该指向../usr/lib # 去开发版上查看 cat@lubancat:/$ ls -l total 5640 lrwxrwxrwx 1 root root 7 Jul 1 2024 bin -> usr/bin drwxr-xr-x 7 root root 4096 Feb 14 18:12 boot drwxr-xr-x 17 root root 4100 Feb 14 18:26 dev drwxrwxr-x 110 1001 1001 4096 Jul 19 2025 etc drwxr-xr-x 3 1001 1001 4096 Sep 4 2023 home lrwxrwxrwx 1 root root 7 Jul 1 2024 lib -> usr/lib ... lrwxrwxrwx 1 root root 8 Jul 1 2024 sbin -> usr/sbin drwxr-xr-x 2 root root 4096 Jul 1 2024 srv ... drwxrwxr-x 10 1001 1001 4096 Feb 14 18:12 usr # 可以明确看到，lib -> usr/lib所以，我猜，需要改变编译服务器的文件夹的指向yoooola@HR000000299:~/WorkSpace/lubanCat/rootFS$ rm lib yoooola@HR000000299:~/WorkSpace/lubanCat/rootFS$ ln -sf usr/lib/ lib yoooola@HR000000299:~/WorkSpace/lubanCat/rootFS$ ll 总用量 12 drwxr-xr-x 3 yoooola yoooola 4096 7月 22 22:02 ./ drwxr-xr-x 5 yoooola yoooola 4096 7月 22 21:55 ../ lrwxrwxrwx 1 yoooola yoooola 8 7月 22 22:02 lib -> usr/lib// drwxr-xr-x 4 yoooola yoooola 4096 7月 22 20:18 usr/改变完以后# 改变链接前 yoooola@HR000000299:~/WorkSpace/lubanCat$ /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-gcc \ oooola/WorkSpace> --sysroot=/home/yoooola/WorkSpace/lubanCat/rootFS \ oola/WorkSpace/lubanCat/rootFS/u> -L/home/yoooola/WorkSpace/lubanCat/rootFS/usr/lib/aarch64-linux-gnu \ > -Wl,-rpath-link=/home/yoooola/WorkSpace/lubanCat/rootFS/usr/lib/aarch64-linux-gnu \ t> test.c -o test /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find crt1.o: 没有那个文件或目录 /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find crti.o: 没有那个文件或目录 /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/aarch64-linux-gnu/libc.so.6 inside /home/yoooola/WorkSpace/lubanCat/rootFS /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 inside /home/yoooola/WorkSpace/lubanCat/rootFS collect2: 错误： ld 返回 1 # 改变链接后 yoooola@HR000000299:~/WorkSpace/lubanCat$ /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-gcc --sysroot=/home/yoooola/WorkSpace/lubanCat/rootFS -L/home/yoooola/WorkSpace/lubanCat/rootFS/usr/lib/aarch64-linux-gnu -Wl,-rpath-link=/home/yoooola/WorkSpace/lubanCat/rootFS/usr/lib/aarch64-linux-gnu test.c -o test /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find crt1.o: 没有那个文件或目录 /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find crti.o: 没有那个文件或目录 collect2: 错误： ld 返回 1# 创建测试的编译文件 yoooola@HR000000299:~/WorkSpace/lubanCat$ echo 'int main() { return 0; }' > test.c yoooola@HR000000299:~/WorkSpace/lubanCat$ /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-gcc \ oooola/WorkSpace> --sysroot=/home/yoooola/WorkSpace/lubanCat/rootFS \ > -Wl,--verbose \ > test.c -o test 2>&1 | grep "attempt to open" attempt to open crt1.o failed attempt to open crti.o failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/crtbegin.o succeeded attempt to open /tmp/ccYQLa54.o succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.a succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libgcc_s.so succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/usr/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/usr/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/aarch64-linux-gnu/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/aarch64-linux-gnu/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/usr/local/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/usr/local/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/usr/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/usr/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/aarch64-linux-gnu/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/aarch64-linux-gnu/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/usr/local/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/usr/local/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/usr/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/usr/lib/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.a succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libgcc_s.so succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/crtend.o succeeded attempt to open crtn.o failed/opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find crt1.o: 没有那个文件或目录# deepseek分析如下 # 从你的 -Wl,--verbose 输出可见，工具链在以下路径中搜索失败： attempt to open crt1.o failed attempt to open crti.o failed attempt to open /home/yoooola/WorkSpace/lubanCat/rootFS/usr/lib/libc.so failed attempt to open crtn.o failed还是有问题，既然文件系统是在debian里面链接过去的，我想直接从底层硬链接过来如何mkdir -p /home/yoooola/WorkSpace/lubanCat/rootFS/lib rsync -avz --rsync-path="sudo rsync" --delete cat@192.168.0.113:/usr/lib /home/yoooola/WorkSpace/lubanCat/rootFS/lib symlinks -rc ~/WorkSpace/lubanCat/rootFS问题依旧1.5 转变思路，对比成功和失败的路径的两者差异拿可以进行编译的根目录环境和不能编译的根目录环境进行对比，看看问题出在哪里# 自己从机器上拿到的环境 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-gcc --sysroot=/home/yoooola/WorkSpace/rootfs -Wl,--verbose test.c -o test 2>&1 | grep "attempt to open" attempt to open crt1.o failed attempt to open crti.o failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/crtbegin.o succeeded attempt to open /tmp/ccjijhhB.o succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.a succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libgcc_s.so succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/../lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/../lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/../lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/../lib64/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/aarch64-linux-gnu/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/aarch64-linux-gnu/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/local/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/local/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/aarch64-linux-gnu/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/aarch64-linux-gnu/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/local/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/local/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.a succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libgcc_s.so succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/crtend.o succeeded attempt to open crtn.o failed/opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory # 从可以编译的rootfs上进行编译 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-gcc --sysroot=/home/yoooola/WorkSpace/rootfs -Wl,--verbose test.c -o test 2>&1 | grep "attempt to open" attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/crt1.o succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/crti.o succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/crtbegin.o succeeded attempt to open /tmp/ccPPhUtQ.o succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.a succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libgcc_s.so succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/libc.so succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/libc.so.6 succeeded attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/aarch64-linux-gnu/libc_nonshared.a succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.a succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libgcc_s.so succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/crtend.o succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/crtn.o succeeded显著区别如下# 失败的库文件查找路径 attempt to open /home/yoooola/WorkSpace/rootfs/lib/../lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/../lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/../lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/../lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/aarch64-linux-gnu/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/aarch64-linux-gnu/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/local/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/local/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib64/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/aarch64-linux-gnu/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/aarch64-linux-gnu/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/local/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/local/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/libc.so failed attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/libc.a failed # 成功的库文件路径 attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/crt1.o succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/crti.o succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/libc.so succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/libc.so.6 succeeded attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/aarch64-linux-gnu/libc_nonshared.a succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/crtn.o succeeded所以，得出结论失踪的crt1.o,crti.o,libc.so,crtn.o是在系统目录下找到的是在这个目录下找到lib/aarch64-linux-gnu/8.3.0继续排查自己是否有这个目录# 野火官方的系统 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace/rootfs$ ls -l ~/WorkSpace/sysroot/usr/lib/aarch64-linux-gnu/8.3.0 lrwxrwxrwx 1 yoooola yoooola 21 Jul 10 2023 /home/yoooola/WorkSpace/sysroot/usr/lib/aarch64-linux-gnu/8.3.0 -> ../aarch64-linux-gnu/ # 自己从机器上同步的库文件，没有 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace/rootfs$ ls usr/lib/aarch64-linux-gnu/8.3.0 ls: cannot access 'usr/lib/aarch64-linux-gnu/8.3.0': No such file or directory # 去机器上看，也米有 cat@lubancat:/usr/lib/aarch64-linux-gnu$ ls 8.3.0 ls: cannot access '8.3.0': No such file or directory所以是不是这里的问题呢？# 手动链接一下 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace/rootfs/usr/lib/aarch64-linux-gnu$ sudo ln -s ../aarch64-linux-gnu 8.3.0 [sudo] password for yoooola: yoooola@LAPTOP-7RPMJTMK:~/WorkSpace/rootfs/usr/lib/aarch64-linux-gnu$ ls -l 8.3.0 lrwxrwxrwx 1 root root 20 Jul 23 00:39 8.3.0 -> ../aarch64-linux-gnu # 再次编译，成功 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-gcc --sysroot=/home/yoooola/WorkSpace/rootfs -Wl,--verbose test.c -o test 2>&1 | grep "attempt to open" attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/crt1.o succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/crti.o succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/crtbegin.o succeeded attempt to open /tmp/cc8reunE.o succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.a succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libgcc_s.so succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libc.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/libc.so succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/libc.so.6 succeeded attempt to open /home/yoooola/WorkSpace/rootfs/usr/lib/aarch64-linux-gnu/libc_nonshared.a succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc.a succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.so failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/libgcc_s.a failed attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/../../../../aarch64-linux-gnu/lib/../lib64/libgcc_s.so succeeded attempt to open /opt/gcc-aarch64-linux-gnu-8.3.0/bin/../lib/gcc/aarch64-linux-gnu/8.3.0/crtend.o succeeded attempt to open /home/yoooola/WorkSpace/rootfs/lib/aarch64-linux-gnu/8.3.0/crtn.o succeeded问题解决# 同理，如果使用aarch64-none-linux-gnu-10.2.1工具直接编译会失败 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ /opt/aarch64-none-linux-gnu-10.2.0/bin/aarch64-none-linux-gnu-gcc --sysroot=/home/yoooola/WorkSpace/rootfs -Wl,--verbose test.c -o test 2>&1 | grep "attempt to open" attempt to open crt1.o failed attempt to open crti.o failed attempt to open /opt/aarch64-none-linux-gnu-10.2.0/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/crtbegin.o succeeded attempt to open /tmp/ccUAwAuW.o succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.0/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.0/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.a succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.0/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc_s.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.0/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc_s.a failed attempt to open /opt/aarch64-none-linux-gnu-10.2.0/bin/../lib/gcc/libgcc_s.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.0/bin/../lib/gcc/libgcc_s.a failed attempt to open /opt/aarch64-none-linux-gnu-10.2.0/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/../../../../aarch64-none-linux-gnu/lib/../lib64/libgcc_s.so succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.0/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/../../../../aarch64-none-linux-gnu/lib/../lib64/libgcc_s.so.1 succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.0/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.0/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.a succeeded # 但是对roofs_debian11进行改造 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace/rootfs_debian11/lib/aarch64-linux-gnu$ ln -s ../aarch64-linux-gnu 10.2.1 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace/rootfs_debian11/lib$ ln -s aarch64-linux-gnu aarch64-none-linux-gnu、 # 检查软连接结果 yoooola@LAPTOP-7RPMJTMK:~$ ls -l ~/WorkSpace/rootfs_debian11/lib/aarch64-none-linux-gnu/10.2.1 lrwxrwxrwx 1 yoooola yoooola 20 Jul 23 01:12 /home/yoooola/WorkSpace/rootfs_debian11/lib/aarch64-none-linux-gnu/10.2.1 -> ../aarch64-linux-gnu yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ ls -l ~/WorkSpace/rootfs_debian11/lib/aarch64-none-linux-gnu lrwxrwxrwx 1 yoooola yoooola 17 Jul 23 01:17 /home/yoooola/WorkSpace/rootfs_debian11/lib/aarch64-none-linux-gnu -> aarch64-linux-gnu # 再次进行编译尝试，成功 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ /opt/aarch64-none-linux-gnu-10.2.1/bin/aarch64-none-linux-gnu-gcc --sysroot=/home/yoooola/WorkSpace/rootfs_debian11 -Wl,--verbose test.c -o test 2>&1 | grep "attempt to open" attempt to open /home/yoooola/WorkSpace/rootfs_debian11/lib/aarch64-none-linux-gnu/10.2.1/crt1.o succeeded attempt to open /home/yoooola/WorkSpace/rootfs_debian11/lib/aarch64-none-linux-gnu/10.2.1/crti.o succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/crtbegin.o succeeded attempt to open /tmp/ccxO7iuJ.o succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.a succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc_s.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc_s.a failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/libgcc_s.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/libgcc_s.a failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/../../../../aarch64-none-linux-gnu/lib/../lib64/libgcc_s.so succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/../../../../aarch64-none-linux-gnu/lib/../lib64/libgcc_s.so.1 succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.a succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libc.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libc.a failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/libc.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/libc.a failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/../../../../aarch64-none-linux-gnu/lib/../lib64/libc.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/../../../../aarch64-none-linux-gnu/lib/../lib64/libc.a failed attempt to open /home/yoooola/WorkSpace/rootfs_debian11/lib/aarch64-none-linux-gnu/10.2.1/libc.so succeeded attempt to open /home/yoooola/WorkSpace/rootfs_debian11/lib/aarch64-linux-gnu/libc.so.6 succeeded attempt to open /home/yoooola/WorkSpace/rootfs_debian11/usr/lib/aarch64-linux-gnu/libc_nonshared.a succeeded attempt to open /home/yoooola/WorkSpace/rootfs_debian11/lib/ld-linux-aarch64.so.1 succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.a succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc_s.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc_s.a failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/libgcc_s.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/libgcc_s.a failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/../../../../aarch64-none-linux-gnu/lib/../lib64/libgcc_s.so succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/../../../../aarch64-none-linux-gnu/lib/../lib64/libgcc_s.so.1 succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.so failed attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/libgcc.a succeeded attempt to open /opt/aarch64-none-linux-gnu-10.2.1/bin/../lib/gcc/aarch64-none-linux-gnu/10.2.1/crtend.o succeeded attempt to open /home/yoooola/WorkSpace/rootfs_debian11/lib/aarch64-none-linux-gnu/10.2.1/crtn.o succeeded # 但是要注意的是include也得链接一下 yoooola@LAPTOP-7RPMJTMK:~$ ln -s ~/WorkSpace/rootfs_debian11/usr/include/aarch64-linux-gnu ~/WorkSpace/rootfs_debian11/usr/include/aarch64-none-linux-gnu yoooola@LAPTOP-7RPMJTMK:~$ ls -l ~/WorkSpace/rootfs_debian11/usr/include/aarch64-none-linux-gnu lrwxrwxrwx 1 yoooola yoooola 17 Jul 23 01:40 /home/yoooola/WorkSpace/rootfs_debian11/usr/include/aarch64-none-linux-gnu -> ~/WorkSpace/rootfs_debian11/usr/include/aarch64-linux-gnu2. 问题总结应该是路径理解问题4. 期间遇到的错误与解决方法4.1 cc1文件权限错误# 报错如下 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ /opt/gcc-aarch64-linux-gnu-8.3.0/bin/aarch64-linux-gnu-gcc --sysroot=/home/yoooola/WorkSpace/rootfs -Wl,--verbose test.c -o test 2>&1 aarch64-linux-gnu-gcc: error trying to exec 'cc1': execvp: No such file or directory # 给与执行权限 yoooola@LAPTOP-7RPMJTMK:~/WorkSpace$ sudo chown -R $USER:$USER /opt/gcc-aarch64-linux-gnu-8.3.0
下载https://download.qt.io/archive/qt/5.15/5.15.2/single/ qt-everywhere-src-5.15.2.tar.xzhttps://download.qt.io/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz交叉编译QT5的库，参考资料野火论坛-交叉编译Qt库(Qt5)构建sysroot在主控板上安装rsync,首先确保主控板已经脸上基础的网络# pull一下源 sudo apt update # 安装rsync sudo apt-get install rsync # 安装ssh客户端 sudo apt-get install openssh-client # 安装ssh服务端 sudo apt-get install openssh-server sudo apt-get install \ libxcb1-dev \ libxcb-xinerama0-dev \ libxcb-icccm4-dev \ libxcb-image0-dev \ libxcb-keysyms1-dev \ libxcb-render-util0-dev \ libxcb-shape0-dev sudo apt-get install -y libx11-dev freetds-dev libpq-dev libiodbc2-dev firebird-dev libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync1 libxcb-sync-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-glx0-dev libxi-dev libdrm-dev libxcb-xinerama0 libxcb-xinerama0-dev libatspi2.0-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxss-dev libxtst-dev libpci-dev libcap-dev libxrandr-dev libdirectfb-dev libaudio-dev libxkbcommon-x11-dev sudo apt-get install -y libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools libunwind-dev sudo apt-get install -y libfreetype6-dev libicu-dev libsqlite3-dev libasound2-dev libnss3-dev libxss-dev libxtst-dev libpci-dev libcap-dev libxrandr-dev libdirectfb-dev libaudio-dev libavcodec-dev libavformat-dev libswscale-dev libts-dev libfontconfig1-dev sudo apt-get install -y libssl-dev libdbus-1-dev libegl1-mesa-dev libgbm-dev libgles2-mesa-dev libgles2-mesa rsyslog libjpeg-dev sudo apt install \ libxcb1-dev:arm64 \ libxcb-xinerama0-dev:arm64 \ libxcb-icccm4-dev:arm64 \ libxcb-image0-dev:arm64 \ libxcb-keysyms1-dev:arm64 \ libxcb-render-util0-dev:arm64 \ libxcb-shape0-dev:arm64 \ libxcb-sync-dev:arm64 \ libxcb-xfixes0-dev:arm64 \ libxcb-xkb-dev:arm64 \ libxkbcommon-x11-dev:arm64 \ libegl1-mesa-dev:arm64 \ libgles2-mesa-dev:arm64在虚拟机上安装rsyncsudo apt-get update sudo apt-get install rsync sudo apt-get install openssh-client sudo apt-get install openssh-server sudo apt-get install libclang-dev sudo dnf install clang-devel sudo apt install libssl-dev gperf pkg-config git bison ninja-build make build-essential libclang-dev libfontconfig1-dev libfreetype6-dev libx11-dev libx11-xcb-dev libxext-dev libxfixes-dev libxi-dev libxrender-dev libxcb1-dev libxcb-glx0-dev libxcb-keysyms1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-icccm4-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-util-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev libatspi2.0-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev建议提前固定好设备的IP，我这里使用路由器固定设备IP为192.168.50.112将当前开发板上的文件系统同步到虚拟机rootfs_copy文件夹在虚拟机上创建rootfs_copy文件夹mkdir -p ~/WorkSpace/rootfs_copy在虚拟机上创建~/.ssh/config 文件:vim ~/.ssh/config在主控板上允许虚拟机登录# 通过其他用户登录（如 linaro） ssh linaro@192.168.50.112 # 切换到 root（需要知道 root 密码） su - root # 编辑 SSH 配置文件 nano /etc/ssh/sshd_config # 输入以下内容 PermitRootLogin yes # 允许 root 登录 PasswordAuthentication yes # 允许密码认证 # 保存后重启ssh服务 systemctl restart ssh开始同步sudo rsync -avx root@192.168.137.202:/ ~/WorkSpace/rootfs_copynfs挂载和rsync同步文件，有些软连接库是使用绝对路径，交叉编译Qt源码时会出错。我们可以使用symlinks修改绝对路径为相对路径，在虚拟机上使用安装命令： sudo apt-get install symlinks 使用命 令： sudo symlinks -rc ~/WorkSpace/rootfs_copy 。安装交叉编译工具链交叉编译器下载地址：https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu.tar.xz编译QT5auto.sh#!/bin/sh ./configure \ -prefix /home/yoooola/WorkSpace/qt5-rk3566 \ -confirm-license \ -opensource \ -release \ -make libs \ -xplatform linux-aarch64-gnu-g++ \ -pch \ -qt-libjpeg \ -qt-libpng \ -qt-zlib \ -opengl es2 \ -eglfs \ -no-sse2 \ -no-openssl \ -no-cups \ -no-glib \ -no-dbus \ -no-separate-debug-info \ 其他组件安装组件所需包RK3566 特定要求OpenGL ESlibgles2Mali-G52 GPU 驱动EGLlibeglRockchip 专用 EGL 实现GBMlibgbmKMS/DRM 支持DRMlibdrm显示控制OpenGL ES 2 安装 sudo apt-get update sudo apt-get install gcc git bison python gperf pkg-config gdb-multiarch sudo apt install build-essential查看系统里是否存在opengl es 的库 - sudo find / -name '*mali*.so*' 2>/dev/null我们这里发现是存在此库文件的/usr/lib/aarch64-linux-gnu/perl/5.32.1/auto/Unicode/Normalize/Normalize.so /usr/lib/aarch64-linux-gnu/rsyslog/mmnormalize.so /usr/lib/aarch64-linux-gnu/libmali_hook.so.1.9.0 /usr/lib/aarch64-linux-gnu/libmali-bifrost-g52-g13p0-x11-gbm.so /usr/lib/aarch64-linux-gnu/libmali.so.1.9.0 /usr/lib/aarch64-linux-gnu/libmali.so /usr/lib/aarch64-linux-gnu/libmali.so.1 /usr/lib/aarch64-linux-gnu/libmali_hook.so /usr/lib/aarch64-linux-gnu/libmali_hook.so.1
原始需求 udp发送数据包结构：起始标志（0x5A,0xA5）2字节报文长度（大端，2字节）命令码0x66（1字节）HMI序号0x00（1字节）保留0x00（1字节）文件名长度n（strlen(文件名)+1，1字节）文件名（绝对路径，包含'0'，n字节）保留0x01（1字节）保留0x00（1字节）校验和（1字节，从起始标志开始算） udp应答报文结构：起始标志0x5A,0xA5（2字节）报文长度（2字节）命令码（1字节）状态码（0x00失败，0x01成功，1字节）校验和（1字节，从起始标志开始算）需求实现 =========================字节打包测试代码===============================#!/usr/bin/env python3 # -*- coding: utf-8 -* import struct import os def calculate_checksum(data): """计算校验和（所有字节累加和的低8位）""" return sum(data) & 0xFF # ================= 发送固件更新数据包构造 ================= def build_request_packet(filename): """ 构造发送数据包 :param filename: 绝对路径文件名(如"/data/test.txt") :return: 字节流数据包 """ # 固定头部字段 start_flag = b'\x5A\xA5' command_code = 0x66 hmi_id = 0x00 reserved1 = 0x00 reserved2 = 0x01 reserved3 = 0x00 # 处理文件名 filename_bytes = filename.encode('utf-8') + b'\x00' # 添加终止符 filename_len = len(filename_bytes) # 包含\0的长度 # 构造可变部分 variable_part = struct.pack('>B', filename_len) + \ filename_bytes + \ struct.pack('>B', reserved2) + \ struct.pack('>B', reserved3) # 计算总长度（从命令码开始到reserved3） """ udp发送数据包结构: 1. 起始标志(0x5A,0xA5)2字节 2. 报文长度(大端, 2字节) 3. 命令码0x66(1字节) 4. HMI序号0x00(1字节) 5. 保留0x00(1字节) 6. 文件名长度n(strlen(文件名)+1, 1字节) 7. 文件名(绝对路径, 包含'0', n字节) 8. 保留0x01(1字节) 9. 保留0x00(1字节) 10. 校验和(1字节, 从起始标志开始算) """ pkt_length = 2 + 2 + 1 + 1 + 1 + 1 + filename_len + 1 + 1 + 1 # 构造完整数据包（先构造未校验部分） packet_without_checksum = struct.pack('>2sHBBBB', start_flag, pkt_length, command_code, hmi_id, reserved1, filename_len) + \ filename_bytes + \ struct.pack('>BB', reserved2, reserved3) # 计算校验和 checksum = calculate_checksum(packet_without_checksum) # 从head开始算 # 添加校验和 return packet_without_checksum + struct.pack('>B', checksum) # ================= 应答数据包解析 ================= def parse_response_packet(data): """ 解析应答数据包 :param data: 字节流数据 :return: 解析后的字典 :raises: ValueError 当数据无效时 """ # 基础校验 if len(data) < 7: raise ValueError("数据包长度不足") """ 1. 起始标志0x5A,0xA5(2字节) 2. 报文长度(2字节) = 7 3. 命令码(1字节) 4. 状态码(0x00失败, 0x01成功, 1字节) 5. 校验和(1字节, 从起始标志开始算) """ # 解析固定部分 start_flag, pkt_length, cmd_code, status, checksum = \ struct.unpack('>2sHBBB', data[:7]) # 校验起始标志 if start_flag != b'\x5A\xA5': raise ValueError("无效的起始标志") # 校验数据包长度 if pkt_length != len(data): raise ValueError(f"长度字段不匹配, 预期 {pkt_length} 字节, 实际 {len(data)} 字节") # 校验和验证 calculated_cs = calculate_checksum(data[:-1]) if checksum != calculated_cs: raise ValueError(f"校验和错误, 预期 {checksum:02X}, 实际 {calculated_cs:02X}") return status # return { # 'start_flag': start_flag.hex(), # 'packet_length': pkt_length, # 'command_code': f'{cmd_code:02X}', # 'status': '成功' if status == 0x01 else '失败', # 'checksum': f'{checksum:02X}' # } def parse_request(data): """解析客户端请求""" if len(data) < 10: raise ValueError("数据包过短") # 解包固定部分 start, length, cmd, hmi, reserved1, filename_len = \ struct.unpack('>2sHBBBB', data[:8]) # 验证起始标志 if start != b'\x5A\xA5': raise ValueError("无效起始标志") # 验证校验和 received_cs = data[-1] calculated_cs = sum(data[:-1]) & 0xFF if received_cs != calculated_cs: raise ValueError(f"校验和错误 {received_cs:02X} vs {calculated_cs:02X}") # 提取文件名 filename_end = 8 + filename_len filename = data[8:filename_end].rstrip(b'\x00').decode('utf-8') return filename def build_response(status): """构建应答数据包""" start_flag = b'\x5A\xA5' cmd_code = 0x66 pkt_length = 7 data_part = start_flag + struct.pack('>HBB', pkt_length, cmd_code, status) checksum = sum(data_part) & 0xFF return data_part + struct.pack('>B', checksum) if __name__ == "__main__": req_pack = build_request_packet('/data/test.txt') print(' '.join(f'{b:02x}' for b in req_pack)) read_path = parse_request(req_pack) print("read_path = " + read_path) res_pack = build_response(1) print(' '.join(f'{b:02x}' for b in res_pack)) res = parse_response_packet(res_pack) print("res = " + str(res)) 部分内容解释 字节顺序控制 字符名称说明@本地序 (默认)与平台相关=本地标准序按原始数据类型大小对齐<小端序低位在前 (Intel x86)>大端序高位在前 (网络协议标准)!网络序等同于 > (推荐用于网络传输) 数据格式 格式字符C 类型Python 类型字节数取值范围（无符号）bsigned charint1-128 ~ 127Bunsigned charint10 ~ 255hshortint2-32768 ~ 32767Hunsigned shortint20 ~ 65535iintint4-2147483648 ~ 2147483647Iunsigned intint40 ~ 4294967295llongint4同 iLunsigned longint4同 Iqlong longint8极大范围Qunsigned long longint80 ~ 2^64-1ffloatfloat4单精度浮点数ddoublefloat8双精度浮点数
景点最终景点选择● 思溪延村-西冲村● 漳村● 理坑● 查平坦（没什么特色景点-也可能是未开发）● 凤山村（古塔）● 察关村● 虹关村路径选择待定● 卧龙谷 - 想要徒步的话可以去（有卧龙瀑布），离住的地方很近● 石城 - 拍晨烟袅袅（但一般是秋天？），需要长焦镜头● 菊径（是一个）不选择去：● 严田村 - 小火车没有了● 美食：出发前准备：服饰及装备公共用品工具[X] 三脚架[X] 折叠椅[X] 充气脚蹬[ ] 驱蚊器[ ] 手电[X] 随车雨伞两把[ ] 外购透明雨伞一把被褥[X] 一次性床单[X] 随车小毯子生活用品[ ] 一次性牙刷数码用品[ ] 相机及电池盒（记得提前清空SD卡）[ ] 充电宝[ ] 降噪耳机[ ] 无人机[ ] 干鞋器便携饮食[X] 随车小零食[ ] 自热米饭或煲仔饭[X] 随车纯净水[X] 随车纸及湿巾[ ] 水果（买苹果和小西红柿）[ ] 口香糖其他[ ] 给女生的小礼物药品[ ] 布洛芬[ ] 阿莫西林女士女士建议装备[ ] 相机[ ] 平板[ ] 热水杯[ ] 帽子（帽子可以带不同风格的，不必苛求遮阳）[ ] 墨镜[ ] 降噪耳机[ ] 化妆品[ ] 防晒霜[ ] 头绳等个人头饰女士衣服：（小清新系和酷酷风）● 可以准备浅色衣服和浅色内衣● 准备裙子或其他合适的衣服（花花绿绿的裙子来一些）● 可以准备雨天的风衣或者帅帅的衣服● 准备徒步（舒服）的鞋子[ ] 需要的卫生用品，如卫生巾[ ] 如果有装饰用的包包可以带上不需要额外准备● 雨伞（买的透明雨伞要带上）● 床单● 充电宝● 纸与湿巾● 相机支架男士男士衣服[ ] 换洗内衣四套[ ] 冲锋衣[ ] 黑色外套[ ] 白色短袖T恤三件[ ] 长袖衬衫[ ] 灯绒裤[ ] 浅色裤子[ ] 深色工装休闲裤[ ] 速干裤[ ] 防晒衣鞋子[X] 随车拖鞋[X] 徒步鞋[ ] 袜子四双其他[ ] 帽子[ ] 大饺子包[ ] 小饺子包[ ] 墨镜[X] 随车眼罩
一、出发及驾车时间：徒步全程约6公里不到，耗时3-4小时开车来回需要4小时 + 两个小时休息时间期望3-4点回，8点到家9:00 从光明宏发上域出发 10:00 点开始徒步 16点完毕 17点周围吃饭 18点看日落，然后回家，2小时后大致20:00回家停车东涌（东涌社区工作站，或OHANA民宿，东涌家园北区停车场，东涌沙滩停车场），西冲打的回东涌（10公里，30分钟）二、需要带的东西着装速干衣服遮阳帽太阳镜两人要背一个包随身相机（肩带）充电宝（带线）能量饮料*2巧克力（士力架）防晒纸巾车内纸巾/湿巾备用衣服备用舒服的鞋子拖鞋矿泉水毛毯魔芋爽（麻酱）三、就餐（晚餐）1. 辉记海上餐厅离得近，饿了就能吃，就餐环境好海胆炒饭清蒸海鱼2. 洞背山庄离得远，需要开车毛蟹食材可以3. 昌记客家美食坊离得近客家咸鸡让豆腐鱼香茄子煲4.阿婆海胆炒饭四、拍照机位天文台栈道（日落）东塘仔巨莽岛海蚀柱