我在使用编译器和交叉编译器从 git 构建 QT6.2 的本机靶心机器上,该编译器和交叉编译器打包在靶心 cmake 版本 3.21 中
首先,我使用为主机构建 QT
jgnoss@mav-dev:~/Devel/QT/qt_x86_64_build$ ../qt_git/configure -prefix /home/jgnoss/Devel/QT/qt_x86_64/6.2.0
配置,构建和安装工作正常
对于交叉编译,我将目标 rootfs sshfs 到:/home/jgnoss/Devel/bbb/sysroot 然后尝试
jgnoss@mav-dev:~/Devel/QT/qt_bbb_build$ ../qt_git/configure -sysroot /home/jgnoss/Devel/bbb/sysroot -qt-host-path /home/jgnoss/Devel/QT/qt_x86_64/6.2.0 -prefix /home/jgnoss/Devel/QT/qt_bbb -extprefix /home/jgnoss/Devel/QT/qt_bbb -DQT_BUILD_TOOLS_WHEN_CROSSCOMPILING=ON -- -DCMAKE_TOOLCHAIN_FILE=/home/jgnoss/Devel/QT/toolchain-cross_armhf.cmake
配置运行良好,但未能检测到安装在目标上的包/库
例如:配置的输出
-- Checking for module 'libudev'
-- No package 'libudev' found
在目标上运行
jgnoss@beaglebone:~$ dpkg -l |grep libudev
ii libgudev-1.0-0:armhf 232-2 armhf G
Object-based wrapper library for libudev
ii libudev-dev:armhf 241-7~deb10u8 armhf l
ibudev development files
ii libudev1:armhf 241-7~deb10u8 armhf l
ibudev shared library
jgnoss@beaglebone:~$ pkg-config --libs libudev
-ludev
这只是一个例子,有很多包/库没有被检测到
任何想法如何解决?
谢谢菊
编辑:我使用的 cmake 工具链文件是:
cmake_minimum_required(VERSION 3.18)
include_guard(GLOBAL)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(TARGET_SYSROOT /home/jgnoss/Devel/bbb/sysroot)
set(CROSS_COMPILER /usr/arm-linux-gnueabihf)
set(CMAKE_SYSROOT ${TARGET_SYSROOT})
set(ENV{PKG_CONFIG_PATH} "")
set(ENV{PKG_CONFIG_LIBDIR} ${CMAKE_SYSROOT}/usr/lib/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig)
set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT})
set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc-10)
set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++-10)
# set(QT_COMPILER_FLAGS "-march=armv7-a -mfpu=neon -mfloat-abi=hard")
# set(QT_COMPILER_FLAGS "-march=armv7-a -mtune=cortex-a9 -mfpu=neon")
#set(QT_COMPILER_FLAGS "-march=armv7-a -mfpu=neon")
set(QT_COMPILER_FLAGS_RELEASE "-O2 -pipe")
set(QT_LINKER_FLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed")
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)
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()