2025年5月14日 星期三

Cross-compile for QT6

先說結論…一定要先編一次x86,才能再cross compiler...= ="
環境:
1. x86 PC
2. 準備STM32MP2 for QT6
3. QT6 version 6.5.3, 下載
4. 因為一直卡在OpenGL的問題
    本來在build_x86編好後,再一個build_aarch64,
    aarch64一直出現OpenGL的問題,MP2的環境應該都有準備好,但還是解不掉
    突然想回頭再試一次x86,也出現一樣的問題@@
    後來砍掉,再解壓一次6.5.3.tar.xz,全部重來,aarch64就可以了 = ="
ERROR: The OpenGL functionality tests failed! You might need to modify the OpenGL package search path by setting the OpenGL_DIR CMake variable to the OpenGL library's installation directory.
CMake Error at qtbase/cmake/QtBuildInformation.cmake:194 (message):
  Check the configuration messages for an error that has occurred.

Call Stack (most recent call first):
  qtbase/cmake/QtBuildInformation.cmake:24 (qt_configure_print_summary)
  CMakeLists.txt:127 (qt_print_feature_summary)
5. 不像QT5,交叉編譯後的qmake,就能幫qt code編成arm平台使用
    QT6的qmake編出來後只能給x86, 但是aarch64用起來就有問題...
    不管是buildroot編出來的
    還是整個6.5.3編出來的...
1. cd output/target/usr/bin
$ file qmake
qmake: POSIX shell script, ASCII text executable
$ file qmake6
qmake6: POSIX shell script, ASCII text executable

aarch64平台
$ ./qmake
./qmake: 7: /home/ubuntu/STMicroelectronics/buildroot_qt653/output/host/bin/qmake6: not found
$ ./qmake6
./qmake6: 7: /home/ubuntu/STMicroelectronics/buildroot_qt653/output/host/bin/qmake6: not found
$ ile /home/ubuntu/STMicroelectronics/buildroot_qt653/output/host/bin/qmake6
/home/ubuntu/STMicroelectronics/buildroot_qt653/output/host/bin/qmake6: ELF 64-bit LSB shared object, x86-64...
為什麼會連到x86...??
試著把此連結用aarch64的qmake6代替,qmake後,就會停在那,不會動
6. 可以用qt-cmake來編專案,只是要寫CmakeLists.txt

======================================================

STM32MP2環境:
1. buildroot-external-st, remotes/origin/st/2024.02.9
2. buildroot, remotes/origin/st/2024.02.9, 6ea7024a34d4e7f994a7d9ded573c340c8adba1e
3. 此版buildroot是6.8.1, 需自行手動更改成6.5.3
4. target config: st_stm32mp257f_dk_defconfig

======================================================

Build QT6.5.3 on x86 PC
$ mkdir build_x86; cd build_x86
$ cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DINPUT_opengl=es2 -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/home/ubuntu/STMicroelectronics/QT6_Source/qt6Host_x86 ..

compile
//build code
//build_x86 folder
$ cmake --build . --parallel 2

//install
cmake --install .

x86 output

Building for: linux-g++ (x86_64, CPU features: mmx sse sse2)
Compiler: gcc 11.4.0
Build options:
  Mode ................................... release (with debug info)
  Optimize release build for size ........ no
  Fully optimize release builds (-O3) .... no
  Building shared libraries .............. yes
  Using C standard ....................... C11
  Using C++ standard ..................... C++17
  Using ccache ........................... no
  Unity Build ............................ no
  Using new DTAGS ........................ yes
  Generating GDB index ................... no
  Relocatable ............................ yes
  Using precompiled headers .............. yes
  Using Link Time Optimization (LTCG) .... no
  Using Intel CET ........................ yes
  Target compiler supports:
    x86 Intrinsics ....................... Basic VAES AVX512VBMI2
  Sanitizers:
    Addresses ............................ no
    Threads .............................. no
    Memory ............................... no
    Fuzzer (instrumentation only) ........ no
    Undefined ............................ no
  Build parts ............................ libs tools
Qt modules and options:
  Qt Concurrent .......................... yes
  Qt D-Bus ............................... yes
  Qt D-Bus directly linked to libdbus .... yes
  Qt Gui ................................. yes
  Qt Network ............................. yes
  Qt PrintSupport ........................ yes
  Qt Sql ................................. yes
  Qt Testlib ............................. yes
  Qt Widgets ............................. yes
  Qt Xml ................................. yes
Support enabled for:
  Using pkg-config ....................... yes
  udev ................................... yes
  OpenSSL ................................ yes
    Qt directly linked to OpenSSL ........ no
  OpenSSL 1.1 ............................ no
  OpenSSL 3.0 ............................ yes
  Using system zlib ...................... yes
  Zstandard support ...................... yes
  Thread support ......................... yes
Common build options:
  Linker can resolve circular dependencies  yes
Qt Core:
  backtrace .............................. yes
  DoubleConversion ....................... yes
    Using system DoubleConversion ........ no
  GLib ................................... yes
  ICU .................................... yes
  Using system libb2 ..................... no
  Built-in copy of the MIME database ..... yes
  cpp/winrt base ......................... no
  Tracing backend ........................ <none>
  Logging backends:
    journald ............................. no
    syslog ............................... no
    slog2 ................................ no
  PCRE2 .................................. yes
    Using system PCRE2 ................... yes
  CLONE_PIDFD support in forkfd .......... yes
  Application permissions ................ no
Qt Sql:
  SQL item models ........................ yes
Qt Network:
  getifaddrs() ........................... yes
  IPv6 ifname ............................ yes
  libproxy ............................... no
  Linux AF_NETLINK ....................... yes
  DTLS ................................... yes
  OCSP-stapling .......................... yes
  SCTP ................................... no
  Use system proxies ..................... yes
  GSSAPI ................................. no
  Brotli Decompression Support ........... yes
  qIsEffectiveTLD() ...................... yes
    Built-in publicsuffix database ....... yes
    System publicsuffix database ......... yes
Core tools:
  Android deployment tool ................ yes
  macOS deployment tool .................. no
  Windows deployment tool ................ no
  qmake .................................. yes
Qt Gui:
  Accessibility .......................... yes
  FreeType ............................... yes
    Using system FreeType ................ yes
  HarfBuzz ............................... yes
    Using system HarfBuzz ................ yes
  Fontconfig ............................. yes
  Image formats:
    GIF .................................. yes
    ICO .................................. yes
    JPEG ................................. yes
      Using system libjpeg ............... yes
    PNG .................................. yes
      Using system libpng ................ yes
  Text formats:
    HtmlParser ........................... yes
    CssParser ............................ yes
    OdfWriter ............................ yes
    MarkdownReader ....................... yes
      Using system libmd4c ............... no
    MarkdownWriter ....................... yes
  EGL .................................... yes
  OpenVG ................................. no
  OpenGL:
    Desktop OpenGL ....................... no
    OpenGL ES 2.0 ........................ yes
    OpenGL ES 3.0 ........................ yes
    OpenGL ES 3.1 ........................ yes
    OpenGL ES 3.2 ........................ yes
  Vulkan ................................. yes
  Session Management ..................... yes
Features used by QPA backends:
  evdev .................................. yes
  libinput ............................... no
  HiRes wheel support in libinput ........ no
  INTEGRITY HID .......................... no
  mtdev .................................. no
  tslib .................................. no
  xkbcommon .............................. yes
  X11 specific:
    XLib ................................. yes
    XCB Xlib ............................. no
    EGL on X11 ........................... yes
    xkbcommon-x11 ........................ no
    xcb-sm ............................... no
QPA backends:
  DirectFB ............................... no
  EGLFS .................................. yes
  EGLFS details:
    EGLFS OpenWFD ........................ no
    EGLFS i.Mx6 .......................... no
    EGLFS i.Mx6 Wayland .................. no
    EGLFS RCAR ........................... no
    EGLFS EGLDevice ...................... yes
    EGLFS GBM ............................ yes
    EGLFS VSP2 ........................... no
    EGLFS Mali ........................... no
    EGLFS Raspberry Pi ................... no
    EGLFS X11 ............................ no
  LinuxFB ................................ yes
  VNC .................................... yes
  VK_KHR_display ......................... yes
  QNX:
    lgmon ................................ no
    IMF .................................. no
  XCB:
    Using system-provided xcb-xinput ..... no
    GL integrations:
      GLX Plugin ......................... no
        XCB GLX .......................... no
      EGL-X11 Plugin ..................... no
  Windows:
    Direct 2D ............................ no
    Direct 2D 1.1 ........................ no
    DirectWrite .......................... no
    DirectWrite 3 ........................ no
Qt Widgets:
  GTK+ ................................... no
  Styles ................................. Fusion Windows
Qt Testlib:
  Tester for item models ................. yes
  Batch tests ............................ no
Qt PrintSupport:
  CUPS ................................... no
Qt Sql Drivers:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. no
  OCI (Oracle) ........................... no
  ODBC ................................... no
  PostgreSQL ............................. no
  SQLite ................................. yes
    Using system provided SQLite ......... no
Further Image Formats:
  JasPer ................................. no
  MNG .................................... no
  TIFF ................................... yes
    Using system libtiff ................. yes
  WEBP ................................... yes
    Using system libwebp ................. no
Qt QML:
  QML network support .................... yes
  QML debugging and profiling support .... yes
  QML just-in-time compiler .............. yes
  QML XML http request ................... yes
  QML Locale ............................. yes
Qt QML Models:
  QML list model ......................... yes
  QML delegate model ..................... yes
Qt Quick:
  AnimatedImage item ..................... yes
  Canvas item ............................ yes
  Support for Qt Quick Designer .......... yes
  Flipable item .......................... yes
  GridView item .......................... yes
  ListView item .......................... yes
  TableView item ......................... yes
  TreeView item .......................... yes
  Path support ........................... yes
  PathView item .......................... yes
  Positioner items ....................... yes
  Repeater item .......................... yes
  ShaderEffect item ...................... yes
  Sprite item ............................ yes
Qt Quick Templates 2:
  Hover support .......................... yes
  Multi-touch support .................... yes
  Calendar support ....................... yes
Qt Quick Controls 2:
  Styles ................................. Basic Fusion Imagine iOS Material Universal macOS Windows
QtQuick3D:
  Assimp ................................. yes
  System Assimp .......................... no
Qt Multimedia:
  Spatial Audio .......................... yes
  Spatial Audio (Quick3D) ................ yes
  Low level Audio Backend:
    ALSA (experimental) .................. no
    PulseAudio ........................... yes
    MMRenderer ........................... no
    CoreAudio ............................ no
    Windows Media SDK .................... no
    Open SLES (Android) .................. no
    Web Assembly ......................... no
  Plugin:
    GStreamer 1.0 ........................ no
    FFmpeg ............................... no
    MMRenderer ........................... no
    AVFoundation ......................... no
    Windows Media Foundation ............. no
  Hardware acceleration and features:
    Video for Linux ...................... yes
    VAAPI support ........................ no
    Linux DMA buffer support ............. yes
    VideoToolbox ......................... no
Qt 3D:
  Assimp ................................. yes
  System Assimp .......................... no
  Use SSE2 instructions .................. yes
  Use AVX2 instructions .................. no
  Aspects:
    Render aspect ........................ yes
    Input aspect ......................... yes
    Logic aspect ......................... yes
    Animation aspect ..................... yes
    Extras aspect ........................ yes
Qt 3D APIs:
  Vulkan ................................. yes
Qt 3D Renderers:
  OpenGL Renderer ........................ yes
  RHI Renderer ........................... yes
Qt3D Geometry Loaders:
  Autodesk FBX ........................... no
Qt 5 Compatibility Libraries:
  iconv .................................. no
Qt Charts Types:
  Area Chart ............................. yes
  Line Chart ............................. yes
  Spline Chart ........................... yes
  Scatter Chart .......................... yes
  Bar Chart .............................. yes
  Pie Chart .............................. yes
  Boxplot Chart .......................... yes
  Candlestick Chart ...................... yes
Qt Axis Types:
  DateTime Axis .......................... yes
Qt Bluetooth:
  BlueZ .................................. no
  BlueZ Low Energy ....................... no
  Linux Crypto API ....................... no
  WinRT Bluetooth API .................... no
Qt Tools:
  Qt Assistant ........................... yes
  QDoc ................................... yes
  Clang-based lupdate parser ............. yes
  Qt Designer ............................ yes
  Qt Distance Field Generator ............ yes
  Qt Linguist ............................ yes
  pixeltool .............................. yes
  qdbus .................................. yes
  Qt Attributions Scanner ................ yes
  qtdiag ................................. yes
  qtplugininfo ........................... yes
Serial Port:
  ntddmodm ............................... no
WebEngine Repository Build Options:
  Build Ninja ............................ no
  Build Gn ............................... yes
  Jumbo Build ............................ yes
  Developer build ........................ no
  Build QtWebEngine Modules:
    Build QtWebEngineCore ................ no
    Build QtWebEngineWidgets ............. no
    Build QtWebEngineQuick ............... no
  Build QtPdf Modules:
    Build QtPdfWidgets ................... no
    Build QtPdfQuick ..................... no
  Optional system libraries:
    re2 .................................. no
    icu .................................. no
    libwebp, libwebpmux and libwebpdemux . no
    opus ................................. no
    ffmpeg ............................... no
    libvpx ............................... no
    snappy ............................... no
    glib ................................. yes
    zlib ................................. yes
    minizip .............................. no
    libevent ............................. yes
    libxml2 and libxslt .................. no
    lcms2 ................................ no
    png .................................. yes
    jpeg ................................. yes
    libopenjpeg2 ......................... no
    harfbuzz ............................. no
    freetype ............................. yes
    libpci ............................... no
Qt Protobuf tools:
  Qt Protobuf generator .................. no
Qt GRPC:
  gRPC support ........................... yes
  Native gRPC support .................... no
Qt GRPC tools:
  Qt GRPC generator ...................... no
Qt Opcua:
  Open62541 .............................. yes
  Unified Automation C++ SDK ............. no
  Support for namespace 0 NodeId names ... yes
  Namespace 0 NodeIds generator .......... no
  Open62541 security support ............. yes
  Support for global discovery server .... yes
Qt Remote Objects:
  High Availability Manager (ham) ........ no
Qt Scxml:
  ECMAScript data model for QtScxml ...... yes
Qt Sensors:
  sensorfw ............................... no
  sensorfw_enabled_with_cmake ............ no
Qt SerialBus:
  Socket CAN ............................. yes
  Socket CAN FD .......................... yes
  SerialPort Support ..................... yes
Qt TextToSpeech:
  Flite .................................. no
  Flite with ALSA ........................ no
  Speech Dispatcher ...................... no
Qt Virtualkeyboard:
  Desktop integration .................... yes
  Built-in layouts ....................... yes
  Key navigation ......................... no
  Retro style as default ................. no
  Sensitive Debug ........................ no
  Cerence ................................ no
    Static Linking ....................... no
    Handwriting .......................... no
      Alphabetic ......................... no
      CJK ................................ no
    XT9 .................................. no
      XT9 Debug .......................... no
      XT9 9-key layouts .................. no
    Bundle resources ..................... no
      Handwriting ........................ no
      XT9 ................................ no
  Hunspell ............................... no
    Using Hunspell copy from 3rdparty/ ... no
  OpenWnn ................................ yes
  MyScript ............................... no
  Language support enabled for:
    Arabic ............................... yes
    Bulgarian ............................ yes
    Czech ................................ yes
    Danish ............................... yes
    German ............................... yes
    Greek ................................ yes
    English GB ........................... yes
    English US ........................... yes
    Spanish .............................. yes
    Spanish Mexico ....................... yes
    Estonian ............................. yes
    Farsi ................................ yes
    Finnish .............................. yes
    French Canada ........................ yes
    French France ........................ yes
    Hebrew ............................... yes
    Hindi ................................ yes
    Croatian ............................. yes
    Hungarian ............................ yes
    Indonesian ........................... yes
    Italian .............................. yes
    Japanese ............................. yes
    Korean ............................... yes
    Malay ................................ yes
    Norwegian ............................ yes
    Dutch ................................ yes
    Polish ............................... yes
    Portuguese Brazil .................... yes
    Portuguese Portugal .................. yes
    Romanian ............................. yes
    Russian .............................. yes
    Slovak ............................... yes
    Slovenian ............................ yes
    Albanian ............................. yes
    Serbian .............................. yes
    Swedish .............................. yes
    Thai ................................. yes
    Turkish .............................. yes
    Ukrainian ............................ yes
    Vietnamese ........................... yes
    Simplified Chinese ................... yes
    Traditional Chinese .................. yes
    HongKong Chinese ..................... no
  Traditional chinese input methods:
    Zhuyin ............................... yes
    Cangjie .............................. yes
Qt Wayland TextInput Protocol V4(WIP) .... no
Qt Wayland Client ........................ yes
Qt Wayland Compositor .................... yes
Qt Wayland Drivers:
  EGL .................................... yes
  Raspberry Pi ........................... no
  DRM EGL ................................ yes
  libhybris EGL .......................... no
  Linux dma-buf server buffer integration  yes
  Shm emulation server buffer integration  yes
  Vulkan-based server buffer integration . yes
Qt Wayland Client Shell Integrations:
  xdg-shell .............................. yes
  ivi-shell .............................. yes
  wl-shell (deprecated) .................. yes
  qt-shell ............................... yes
Qt Wayland Compositor Layer Plugins:
  VSP2 hardware layer integration ........ no
Note: Hunspell in Qt Virtual Keyboard is not enabled. Spelling correction will not be available.
WARNING: QtWebEngine won't be built. Python3 html5lib is missing.
WARNING: QtPdf won't be built. Python3 html5lib is missing.
WARNING: SensorFW support currently not enabled with cmake

==========================================================
Build QT6.5.3 for aarch64
1. Create a sysroot folder, ex, $HOME/STMicroelectronics/QT6_Source/sysroot
    a. Copy it from buildroot, ex: $HOME/STMicroelectronics/buildroot_qt653/output/host/aarch64-  buildroot-linux-gnu/sysroot
    or
    b. Copy usr/ and lib/ from your target aarch64 platform.
$ ls /home/ubuntu/STMicroelectronics/buildroot_qt653/output/host/aarch64-buildroot-linux-gnu/sysroot
bin  dev  etc  lib  lib64(softlink to lib)  media  mnt  opt  proc  root  run  sbin  sys  tmp  usr  var

2. aarch64.cmake, copy it from 鲁班猫Qt应用开发实战
# 这里设置cmake支持的最小版本
cmake_minimum_required(VERSION 3.18)
include_guard(GLOBAL)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

# 指定sysroot目录
set(TARGET_SYSROOT /home/ubuntu/STMicroelectronics/QT6_Source/sysroot)

# 指定前面获取的交叉编译器路径
set(CROSS_COMPILER /usr/bin/aarch64-linux-gnu)

set(CMAKE_SYSROOT ${TARGET_SYSROOT})

set(CMAKE_C_COMPILER ${CROSS_COMPILER}-gcc)
set(CMAKE_CXX_COMPILER ${CROSS_COMPILER}-g++)

set(CMAKE_LIBRARY_ARCHITECTURE )

# 库路径
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wl,-rpath-link,${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE} -fPIC -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} -L${CMAKE_SYSROOT}/usr/lib -I${TARGET_SYSROOT}/usr/include -I${TARGET_SYSROOT}/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")

# 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(QT_COMPILER_FLAGS "-march=armv8-a")
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")

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()

3. Cross compile on x86 PC
 $ mkdir build_aarch64; cd build_aarch64
$ cmake -GNinja \
      -DCMAKE_BUILD_TYPE=Release \
      -DINPUT_opengl=es2 \
      -DQT_BUILD_EXAMPLES=OFF \
      -DQT_BUILD_TESTS=OFF \
      -DQT_HOST_PATH=/home/ubuntu/STMicroelectronics/QT6_Source/qt6Host_x86 \
      -DCMAKE_STAGING_PREFIX=/home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix \
      -DCMAKE_INSTALL_PREFIX=/home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix \
      -DCMAKE_TOOLCHAIN_FILE=/home/ubuntu/STMicroelectronics/QT6_Source/qt-everywhere-src-6.5.3/aarch64.cmake \
      -DQT_FEATURE_xcb=ON \
      -DFEATURE_xcb_xlib=ON \
      -DQT_FEATURE_xlib=ON \
      -DFEATURE_qtwebengine_build=OFF ..


aarch64 output:


-- Configure summary:

Building for: linux-g++ (arm64, CPU features: cx16 neon)
Compiler: gcc 11.4.0
Build options:
  Mode ................................... release
  Optimize release build for size ........ no
  Fully optimize release builds (-O3) .... no
  Building shared libraries .............. yes
  Using C standard ....................... C11
  Using C++ standard ..................... C++17
  Using ccache ........................... no
  Unity Build ............................ no
  Using new DTAGS ........................ yes
  Relocatable ............................ yes
  Using precompiled headers .............. yes
  Using Link Time Optimization (LTCG) .... no
  Using Intel CET ........................ no
  Target compiler supports:
    ARM Extensions ....................... NEON
  Sanitizers:
    Addresses ............................ no
    Threads .............................. no
    Memory ............................... no
    Fuzzer (instrumentation only) ........ no
    Undefined ............................ no
  Build parts ............................ libs
Qt modules and options:
  Qt Concurrent .......................... yes
  Qt D-Bus ............................... yes
  Qt D-Bus directly linked to libdbus .... yes
  Qt Gui ................................. yes
  Qt Network ............................. yes
  Qt PrintSupport ........................ yes
  Qt Sql ................................. yes
  Qt Testlib ............................. yes
  Qt Widgets ............................. yes
  Qt Xml ................................. yes
Support enabled for:
  Using pkg-config ....................... yes
  udev ................................... no
  OpenSSL ................................ yes
    Qt directly linked to OpenSSL ........ no
  OpenSSL 1.1 ............................ no
  OpenSSL 3.0 ............................ yes
  Using system zlib ...................... yes
  Zstandard support ...................... no
  Thread support ......................... yes
Common build options:
  Linker can resolve circular dependencies  yes
Qt Core:
  backtrace .............................. yes
  DoubleConversion ....................... yes
    Using system DoubleConversion ........ yes
  GLib ................................... yes
  ICU .................................... no
  Using system libb2 ..................... yes
  Built-in copy of the MIME database ..... yes
  cpp/winrt base ......................... no
  Tracing backend ........................ <none>
  Logging backends:
    journald ............................. no
    syslog ............................... no
    slog2 ................................ no
  PCRE2 .................................. yes
    Using system PCRE2 ................... yes
  CLONE_PIDFD support in forkfd .......... yes
  Application permissions ................ no
Qt Sql:
  SQL item models ........................ yes
Qt Network:
  getifaddrs() ........................... yes
  IPv6 ifname ............................ yes
  libproxy ............................... no
  Linux AF_NETLINK ....................... yes
  DTLS ................................... yes
  OCSP-stapling .......................... yes
  SCTP ................................... no
  Use system proxies ..................... yes
  GSSAPI ................................. no
  Brotli Decompression Support ........... no
  qIsEffectiveTLD() ...................... yes
    Built-in publicsuffix database ....... yes
    System publicsuffix database ......... yes
Core tools:
  Android deployment tool ................ no
  macOS deployment tool .................. no
  Windows deployment tool ................ no
  qmake .................................. yes
Qt Gui:
  Accessibility .......................... yes
  FreeType ............................... yes
    Using system FreeType ................ yes
  HarfBuzz ............................... yes
    Using system HarfBuzz ................ no
  Fontconfig ............................. yes
  Image formats:
    GIF .................................. yes
    ICO .................................. yes
    JPEG ................................. yes
      Using system libjpeg ............... yes
    PNG .................................. yes
      Using system libpng ................ yes
  Text formats:
    HtmlParser ........................... yes
    CssParser ............................ yes
    OdfWriter ............................ yes
    MarkdownReader ....................... yes
      Using system libmd4c ............... no
    MarkdownWriter ....................... yes
  EGL .................................... yes
  OpenVG ................................. no
  OpenGL:
    Desktop OpenGL ....................... no
    OpenGL ES 2.0 ........................ yes
    OpenGL ES 3.0 ........................ yes
    OpenGL ES 3.1 ........................ yes
    OpenGL ES 3.2 ........................ yes
  Vulkan ................................. no
  Session Management ..................... yes
Features used by QPA backends:
  evdev .................................. yes
  libinput ............................... no
  HiRes wheel support in libinput ........ no
  INTEGRITY HID .......................... no
  mtdev .................................. no
  tslib .................................. no
  xkbcommon .............................. no
  X11 specific:
    xlib ................................. yes
    XCB Xlib ............................. yes
    EGL on X11 ........................... no
    xkbcommon-x11 ........................ no
    xcb-sm ............................... no
QPA backends:
  DirectFB ............................... no
  EGLFS .................................. yes
  EGLFS details:
    EGLFS OpenWFD ........................ no
    EGLFS i.Mx6 .......................... no
    EGLFS i.Mx6 Wayland .................. no
    EGLFS RCAR ........................... no
    EGLFS EGLDevice ...................... yes
    EGLFS GBM ............................ yes
    EGLFS VSP2 ........................... no
    EGLFS Mali ........................... no
    EGLFS Raspberry Pi ................... no
    EGLFS X11 ............................ no
  LinuxFB ................................ yes
  VNC .................................... yes
  VK_KHR_display ......................... no
  QNX:
    lgmon ................................ no
    IMF .................................. no
  XCB:
    Using system-provided xcb-xinput ..... no
    GL integrations:
      GLX Plugin ......................... no
        XCB GLX .......................... no
      EGL-X11 Plugin ..................... yes
  Windows:
    Direct 2D ............................ no
    Direct 2D 1.1 ........................ no
    DirectWrite .......................... no
    DirectWrite 3 ........................ no
Qt Widgets:
  GTK+ ................................... no
  Styles ................................. Fusion Windows
Qt Testlib:
  Tester for item models ................. yes
  Batch tests ............................ no
Qt PrintSupport:
  CUPS ................................... no
Qt Sql Drivers:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. no
  OCI (Oracle) ........................... no
  ODBC ................................... no
  PostgreSQL ............................. no
  SQLite ................................. yes
    Using system provided SQLite ......... no
Further Image Formats:
  JasPer ................................. no
  MNG .................................... no
  TIFF ................................... yes
    Using system libtiff ................. no
  WEBP ................................... yes
    Using system libwebp ................. no
Qt QML:
  QML network support .................... yes
  QML debugging and profiling support .... yes
  QML just-in-time compiler .............. yes
  QML XML http request ................... yes
  QML Locale ............................. yes
Qt QML Models:
  QML list model ......................... yes
  QML delegate model ..................... yes
Qt Quick:
  AnimatedImage item ..................... yes
  Canvas item ............................ yes
  Support for Qt Quick Designer .......... yes
  Flipable item .......................... yes
  GridView item .......................... yes
  ListView item .......................... yes
  TableView item ......................... yes
  TreeView item .......................... yes
  Path support ........................... yes
  PathView item .......................... yes
  Positioner items ....................... yes
  Repeater item .......................... yes
  ShaderEffect item ...................... yes
  Sprite item ............................ yes
Qt Quick Templates 2:
  Hover support .......................... yes
  Multi-touch support .................... yes
  Calendar support ....................... yes
Qt Quick Controls 2:
  Styles ................................. Basic Fusion Imagine iOS Material Universal macOS Windows
QtQuick3D:
  Assimp ................................. yes
  System Assimp .......................... no
Qt Multimedia:
  Spatial Audio .......................... yes
  Spatial Audio (Quick3D) ................ yes
  Low level Audio Backend:
    ALSA (experimental) .................. no
    PulseAudio ........................... yes
    MMRenderer ........................... no
    CoreAudio ............................ no
    Windows Media SDK .................... no
    Open SLES (Android) .................. no
    Web Assembly ......................... no
  Plugin:
    GStreamer 1.0 ........................ yes
    FFmpeg ............................... no
    MMRenderer ........................... no
    AVFoundation ......................... no
    Windows Media Foundation ............. no
  Hardware acceleration and features:
    Video for Linux ...................... yes
    VAAPI support ........................ no
    Linux DMA buffer support ............. yes
    VideoToolbox ......................... no
Qt 3D:
  Assimp ................................. yes
  System Assimp .......................... no
  Use SSE2 instructions .................. no
  Use AVX2 instructions .................. no
  Aspects:
    Render aspect ........................ yes
    Input aspect ......................... yes
    Logic aspect ......................... yes
    Animation aspect ..................... yes
    Extras aspect ........................ yes
Qt 3D APIs:
  Vulkan ................................. no
Qt 3D Renderers:
  OpenGL Renderer ........................ yes
  RHI Renderer ........................... yes
Qt3D Geometry Loaders:
  Autodesk FBX ........................... no
Qt 5 Compatibility Libraries:
  iconv .................................. yes
Qt Charts Types:
  Area Chart ............................. yes
  Line Chart ............................. yes
  Spline Chart ........................... yes
  Scatter Chart .......................... yes
  Bar Chart .............................. yes
  Pie Chart .............................. yes
  Boxplot Chart .......................... yes
  Candlestick Chart ...................... yes
Qt Axis Types:
  DateTime Axis .......................... yes
Qt Bluetooth:
  BlueZ .................................. no
  BlueZ Low Energy ....................... no
  Linux Crypto API ....................... no
  WinRT Bluetooth API .................... no
Qt Tools:
  Qt Assistant ........................... yes
  QDoc ................................... no
  Clang-based lupdate parser ............. no
  Qt Designer ............................ yes
  Qt Distance Field Generator ............ yes
  Qt Linguist ............................ yes
  pixeltool .............................. yes
  qdbus .................................. yes
  Qt Attributions Scanner ................ yes
  qtdiag ................................. yes
  qtplugininfo ........................... yes
Serial Port:
  ntddmodm ............................... no
WebEngine Repository Build Options:
  Build Ninja ............................ no
  Build Gn ............................... yes
  Jumbo Build ............................ yes
  Developer build ........................ no
  Build QtWebEngine Modules:
    Build QtWebEngineCore ................ no
    Build QtWebEngineWidgets ............. no
    Build QtWebEngineQuick ............... no
  Build QtPdf Modules:
    Build QtPdfWidgets ................... no
    Build QtPdfQuick ..................... no
  Optional system libraries:
    re2 .................................. no
    icu .................................. no
    libwebp, libwebpmux and libwebpdemux . no
    opus ................................. no
    ffmpeg ............................... no
    libvpx ............................... no
    snappy ............................... no
    glib ................................. yes
    zlib ................................. yes
    minizip .............................. no
    libevent ............................. no
    libxml2 and libxslt .................. no
    lcms2 ................................ no
    png .................................. yes
    jpeg ................................. yes
    libopenjpeg2 ......................... no
    harfbuzz ............................. no
    freetype ............................. yes
    libpci ............................... no
Qt Protobuf tools:
  Qt Protobuf generator .................. no
Qt GRPC:
  gRPC support ........................... yes
  Native gRPC support .................... no
Qt GRPC tools:
  Qt GRPC generator ...................... no
Qt Opcua:
  Open62541 .............................. yes
  Unified Automation C++ SDK ............. no
  Support for namespace 0 NodeId names ... yes
  Namespace 0 NodeIds generator .......... no
  Open62541 security support ............. yes
  Support for global discovery server .... yes
Qt Remote Objects:
  High Availability Manager (ham) ........ no
Qt Scxml:
  ECMAScript data model for QtScxml ...... yes
Qt Sensors:
  sensorfw ............................... no
  sensorfw_enabled_with_cmake ............ no
Qt SerialBus:
  Socket CAN ............................. yes
  Socket CAN FD .......................... yes
  SerialPort Support ..................... yes
Qt TextToSpeech:
  Flite .................................. no
  Flite with ALSA ........................ no
  Speech Dispatcher ...................... no
Qt Virtualkeyboard:
  Desktop integration .................... yes
  Built-in layouts ....................... yes
  Key navigation ......................... no
  Retro style as default ................. no
  Sensitive Debug ........................ no
  Cerence ................................ no
    Static Linking ....................... no
    Handwriting .......................... no
      Alphabetic ......................... no
      CJK ................................ no
    XT9 .................................. no
      XT9 Debug .......................... no
      XT9 9-key layouts .................. no
    Bundle resources ..................... no
      Handwriting ........................ no
      XT9 ................................ no
  Hunspell ............................... no
    Using Hunspell copy from 3rdparty/ ... no
  OpenWnn ................................ yes
  MyScript ............................... no
  Language support enabled for:
    Arabic ............................... yes
    Bulgarian ............................ yes
    Czech ................................ yes
    Danish ............................... yes
    German ............................... yes
    Greek ................................ yes
    English GB ........................... yes
    English US ........................... yes
    Spanish .............................. yes
    Spanish Mexico ....................... yes
    Estonian ............................. yes
    Farsi ................................ yes
    Finnish .............................. yes
    French Canada ........................ yes
    French France ........................ yes
    Hebrew ............................... yes
    Hindi ................................ yes
    Croatian ............................. yes
    Hungarian ............................ yes
    Indonesian ........................... yes
    Italian .............................. yes
    Japanese ............................. yes
    Korean ............................... yes
    Malay ................................ yes
    Norwegian ............................ yes
    Dutch ................................ yes
    Polish ............................... yes
    Portuguese Brazil .................... yes
    Portuguese Portugal .................. yes
    Romanian ............................. yes
    Russian .............................. yes
    Slovak ............................... yes
    Slovenian ............................ yes
    Albanian ............................. yes
    Serbian .............................. yes
    Swedish .............................. yes
    Thai ................................. yes
    Turkish .............................. yes
    Ukrainian ............................ yes
    Vietnamese ........................... yes
    Simplified Chinese ................... yes
    Traditional Chinese .................. yes
    HongKong Chinese ..................... no
  Traditional chinese input methods:
    Zhuyin ............................... yes
    Cangjie .............................. yes
Qt Wayland TextInput Protocol V4(WIP) .... no
Qt Wayland Client ........................ yes
Qt Wayland Compositor .................... yes
Qt Wayland Drivers:
  EGL .................................... yes
  Raspberry Pi ........................... no
  DRM EGL ................................ yes
  libhybris EGL .......................... no
  Linux dma-buf server buffer integration  yes
  Shm emulation server buffer integration  yes
  Vulkan-based server buffer integration . no
Qt Wayland Client Shell Integrations:
  xdg-shell .............................. yes
  ivi-shell .............................. yes
  wl-shell (deprecated) .................. yes
  qt-shell ............................... yes
Qt Wayland Compositor Layer Plugins:
  VSP2 hardware layer integration ........ no


NNote: Disabling X11 Accessibility Bridge: D-Bus or AT-SPI is missing.
Note: Hunspell in Qt Virtual Keyboard is not enabled. Spelling correction will not be available.
Note: Due to CMAKE_STAGING_PREFIX usage and an unfixed CMake bug,
      to ensure correct build time rpaths, directory-level install
      rules like ninja src/gui/install will not work.
      Check QTBUG-102592 for further details.

WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.
Either set CMAKE_PREFIX_PATH or 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.
You will also need to set the FEATURE_clang CMake variable to ON to re-evaluate this check.
WARNING: Clang-based lupdate parser will not be available. LLVM and Clang C++ libraries have not been found.
You will need to set the FEATURE_clangcpp CMake variable to ON to re-evaluate this check.
WARNING: QtWebEngine won't be built. Python3 html5lib is missing.
WARNING: QtPdf won't be built. Python3 html5lib is missing.
WARNING: SensorFW support currently not enabled with cmake

--

Qt is now configured for building. Just run 'cmake --build . --parallel'

Once everything is built, you must run 'cmake --install .'
Qt will be installed into '/home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix'

To configure and build other Qt modules, you can use the following convenience script:
        /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix/bin/qt-configure-module

If reconfiguration fails for some reason, try removing 'CMakeCache.txt' from the build directory
Alternatively, you can add the --fresh flag to your CMake flags.

-- Configuring done (27.5s)
-- Generating done (3.9s)
-- Build files have been written to: /home/ubuntu/STMicroelectronics/QT6_Source/qt-everywhere-src-6.5.3/build_aarch64

compile
//build code
//不要用ninja build
$ cmake --build . --parallel 2

//install
$ cmake --install .

hello專案
$ ls
CMakeLists.txt  main.cpp

-----------------------------------------------------

main.cpp
#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[]) {
  QApplication app(argc, argv);
  QLabel label("Hello World");
  label.setWindowTitle("Hello World");
  label.resize(200, 100);
  label.show();
  return app.exec();
}

-----------------------------------------------------

 cat CMakeLists.txt
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

cmake_minimum_required(VERSION 3.16)
project(hellogl2 LANGUAGES CXX)


#AARCH64
set(TARGET_SYSROOT /home/ubuntu/STMicroelectronics/QT6_Source/sysroot)
set(CROSS_COMPILER /usr/bin/aarch64-linux-gnu)
set(CMAKE_SYSROOT ${TARGET_SYSROOT})

set(CMAKE_C_COMPILER ${CROSS_COMPILER}-gcc)
set(CMAKE_CXX_COMPILER ${CROSS_COMPILER}-g++)
set(CMAKE_LIBRARY_ARCHITECTURE)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wl,-rpath-link,${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE} -fPIC -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} -L${CMAKE_SYSROOT}/usr/lib -I${TARGET_SYSROOT}/usr/include -I${TARGET_SYSROOT}/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
#end for AARCH64

find_package(Qt6 REQUIRED COMPONENTS Widgets)

qt_standard_project_setup()

qt_add_executable(hello
    main.cpp
)

set_target_properties(hello PROPERTIES
    WIN32_EXECUTABLE TRUE
    MACOSX_BUNDLE TRUE
)

target_link_libraries(hello PRIVATE
    Qt6::Widgets
)

Cross-compile hello project
$ file /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix/bin/qt-cmake
/home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix/bin/qt-cmake: POSIX shell script, ASCII text executable

$ mkdir build_aarch64; cd build_aarch64
$ /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix/bin/qt-cmake ..
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
-- Performing Test HAVE_EGL
-- Performing Test HAVE_EGL - Success
-- Found EGL: /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/usr/include (found version "1.5")
-- Performing Test HAVE_GLESv2
-- Performing Test HAVE_GLESv2 - Success
-- Found GLESv2: /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/usr/include
-- Found XKB: /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/usr/lib/libxkbcommon.so (found suitable version "1.4.0", minimum required is "0.5.0")
-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: /home/ubuntu/STMicroelectronics/QT6/hello/build_aarch64

$ cmake --build .
[  0%] Built target hello_autogen_timestamp_deps
[ 20%] Automatic MOC and UIC for target hello
[ 20%] Built target hello_autogen
[ 40%] Building CXX object CMakeFiles/hello.dir/hello_autogen/mocs_compilation.cpp.o
[ 60%] Building CXX object CMakeFiles/hello.dir/main.cpp.o
[ 80%] Linking CXX executable hello
[100%] Built target hello

$ file ./hello
hello: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=2bccf14786fd2d593f5ae8d64847d30365ca2f4b, not stripped

ref:
1. 鲁班猫Qt应用开发实战

沒有留言:

張貼留言