Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Using cross-compilation for ARM64 in the Ubuntu 24.04 x86 environment
Forum Updated to NodeBB v4.3 + New Features

Using cross-compilation for ARM64 in the Ubuntu 24.04 x86 environment

Scheduled Pinned Locked Moved Solved Installation and Deployment
4 Posts 2 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Steven LIN
    wrote on last edited by
    #1

    I would like to ask if my setup is correct. Why does the file not change to ARM64 after running cmake --install . ?

    sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
    
    $ which aarch64-linux-gnu-gcc 
    /usr/bin/aarch64-linux-gnu-gcc
    
    $ aarch64-linux-gnu-gcc --version
    aarch64-linux-gnu-gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
    Copyright (C) 2023 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    

    After verifying the cross-compilation tool, enter the Qt/6.8.2/ directory, create a folder, and start compiling.

    cd ./Qt/6.8.2/
    mkdir arm64 
    mkdir build && cd build
    
    ../Src/configure -prefix /home/ptc/Qt/6.8.2/arm64 -platform linux-g++ -device linux-aarch64-gnu-g++ -device-option CROSS_COMPILE=aarch64-linux-gnu- -no-opengl -make libs 
    
    

    Using the file command to check the file, it is still x86.

    $ file /home/ptc/Qt/6.8.2/arm64/lib/libQt6Quick.so.6.8.2
    /home/ptc/Qt/6.8.2/arm64/lib/libQt6Quick.so.6.8.2: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=98b91422f304c376f1f70edb73b6276205a6027b, not stripped
    
    

    It also cannot be executed on Qt Creator.
    ea7c30e3-9672-41a5-9b24-6410c5493b89-image.png
    1e098032-b2bf-4d48-8339-f6b9fa2553f4-image.png
    e44d33c9-6fd2-4148-84cb-0b94b79cc370-image.png
    fa40b4f1-f323-43a6-819b-c49f89c592c5-image.png

    I would like to ask how I can resolve this issue. I would greatly appreciate it.

    jsulmJ 1 Reply Last reply
    0
    • S Offline
      S Offline
      Steven LIN
      wrote on last edited by
      #4

      I have already resolved the issue and successfully cross-compiled for arm64 on Ubuntu 24.04 x86 using Qt6.8.2.

      I will provide my method.
      The configure command is as follows:

      ../Src/configure \
      -prefix /home/ptc/Qt/6.8.2/arm64 \
      -qt-host-path /home/ptc/Qt/6.8.2/gcc_64 \
      -platform linux-g++ \
      -device linux-aarch64-gnu-g++ \
      -device-option CROSS_COMPILE=aarch64-linux-gnu- \
      -no-opengl \
      -skip qtopcua -skip qtwebengine -skip qtwebview -skip qtserialport -skip qtlocation \
      -no-feature-brotli -no-feature-hunspell \
      -- -DCMAKE_TOOLCHAIN_FILE=$HOME/Qt/6.8.2/toolchain/arm64-toolchain.cmake 
      

      Before this, create a new toolchain.cmake file yourself.

      set(CMAKE_SYSTEM_NAME Linux)
      set(CMAKE_SYSTEM_PROCESSOR aarch64)
      set(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-gcc")
      set(CMAKE_CXX_COMPILER "/usr/bin/aarch64-linux-gnu-g++")
      set(CMAKE_LINKER "/usr/bin/aarch64-linux-gnu-ld")
      set(CMAKE_AR "/usr/bin/aarch64-linux-gnu-ar")
      set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)
      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)
      

      Next, you can follow my method to add the arm64-related dependencies on x86.

      $ sudo dpkg --add-architecture arm64
      $ sudo vim /etc/apt/sources.list.d/ubuntu-arm64.sources
      Types: deb
      URIs: http://ports.ubuntu.com/ubuntu-ports/
      Suites: noble noble-updates noble-security
      Components: main restricted universe multiverse
      Architectures: arm64
      Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
      
      $ sudo apt update
      $ sudo apt install -y libudev-dev:arm64 libmtdev-dev:arm64
      

      Finally, execute the configure command.

      1 Reply Last reply
      0
      • S Steven LIN

        I would like to ask if my setup is correct. Why does the file not change to ARM64 after running cmake --install . ?

        sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
        
        $ which aarch64-linux-gnu-gcc 
        /usr/bin/aarch64-linux-gnu-gcc
        
        $ aarch64-linux-gnu-gcc --version
        aarch64-linux-gnu-gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
        Copyright (C) 2023 Free Software Foundation, Inc.
        This is free software; see the source for copying conditions.  There is NO
        warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
        

        After verifying the cross-compilation tool, enter the Qt/6.8.2/ directory, create a folder, and start compiling.

        cd ./Qt/6.8.2/
        mkdir arm64 
        mkdir build && cd build
        
        ../Src/configure -prefix /home/ptc/Qt/6.8.2/arm64 -platform linux-g++ -device linux-aarch64-gnu-g++ -device-option CROSS_COMPILE=aarch64-linux-gnu- -no-opengl -make libs 
        
        

        Using the file command to check the file, it is still x86.

        $ file /home/ptc/Qt/6.8.2/arm64/lib/libQt6Quick.so.6.8.2
        /home/ptc/Qt/6.8.2/arm64/lib/libQt6Quick.so.6.8.2: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=98b91422f304c376f1f70edb73b6276205a6027b, not stripped
        
        

        It also cannot be executed on Qt Creator.
        ea7c30e3-9672-41a5-9b24-6410c5493b89-image.png
        1e098032-b2bf-4d48-8339-f6b9fa2553f4-image.png
        e44d33c9-6fd2-4148-84cb-0b94b79cc370-image.png
        fa40b4f1-f323-43a6-819b-c49f89c592c5-image.png

        I would like to ask how I can resolve this issue. I would greatly appreciate it.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @Steven-LIN Please don't double post.
        This is same as https://forum.qt.io/topic/161304/using-cross-compilation-for-arm64-in-the-ubuntu-24-04-x86-environment?_=1741068261682

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        S 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Steven-LIN Please don't double post.
          This is same as https://forum.qt.io/topic/161304/using-cross-compilation-for-arm64-in-the-ubuntu-24-04-x86-environment?_=1741068261682

          S Offline
          S Offline
          Steven LIN
          wrote on last edited by
          #3

          @jsulm Sorry, I have already deleted the previous post.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Steven LIN
            wrote on last edited by
            #4

            I have already resolved the issue and successfully cross-compiled for arm64 on Ubuntu 24.04 x86 using Qt6.8.2.

            I will provide my method.
            The configure command is as follows:

            ../Src/configure \
            -prefix /home/ptc/Qt/6.8.2/arm64 \
            -qt-host-path /home/ptc/Qt/6.8.2/gcc_64 \
            -platform linux-g++ \
            -device linux-aarch64-gnu-g++ \
            -device-option CROSS_COMPILE=aarch64-linux-gnu- \
            -no-opengl \
            -skip qtopcua -skip qtwebengine -skip qtwebview -skip qtserialport -skip qtlocation \
            -no-feature-brotli -no-feature-hunspell \
            -- -DCMAKE_TOOLCHAIN_FILE=$HOME/Qt/6.8.2/toolchain/arm64-toolchain.cmake 
            

            Before this, create a new toolchain.cmake file yourself.

            set(CMAKE_SYSTEM_NAME Linux)
            set(CMAKE_SYSTEM_PROCESSOR aarch64)
            set(CMAKE_C_COMPILER "/usr/bin/aarch64-linux-gnu-gcc")
            set(CMAKE_CXX_COMPILER "/usr/bin/aarch64-linux-gnu-g++")
            set(CMAKE_LINKER "/usr/bin/aarch64-linux-gnu-ld")
            set(CMAKE_AR "/usr/bin/aarch64-linux-gnu-ar")
            set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)
            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)
            

            Next, you can follow my method to add the arm64-related dependencies on x86.

            $ sudo dpkg --add-architecture arm64
            $ sudo vim /etc/apt/sources.list.d/ubuntu-arm64.sources
            Types: deb
            URIs: http://ports.ubuntu.com/ubuntu-ports/
            Suites: noble noble-updates noble-security
            Components: main restricted universe multiverse
            Architectures: arm64
            Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
            
            $ sudo apt update
            $ sudo apt install -y libudev-dev:arm64 libmtdev-dev:arm64
            

            Finally, execute the configure command.

            1 Reply Last reply
            0
            • S Steven LIN has marked this topic as solved on

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved