User:Joger/Building Qt Multimedia for Android: Difference between revisions
m (Joger moved page Building Qt Multimedia for Android to User:Joger/Building Qt Multimedia for Android) |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== About this page == | == About this page == | ||
On this page I describe how I build Qt Multimedia for Android | On this page, I describe how I build Qt for my Android device, which is a Samsung Galaxy S6. I work primarily with Qt Multimedia. I therefore need a build setup that makes it easy to debug, run tests, and examples from within an IDE without spending too much time on reconfiguring and rebuilding all of Qt. This tutorial follows the steps from the official Qt documentation at [https://doc.qt.io/qt-6/android-building.html Qt for Android - Building from Source | Qt 6.7]. In addition, I show how to configure Qt as a separate submodule to reduce the need for reconfiguring and rebuilding all of Qt. | ||
==My build setup== | ==My build setup== | ||
* OS: Windows 11 with dev drive mounted on | * OS: Windows 11 with dev drive mounted on K: (Using a dev drive makes builds faster when using Windows Defender antivirus) | ||
* Qt source tree: | * Qt source tree: K:\qt\android\qt6 | ||
* Build directory | * Build directory main Android build: K:\qt\android\android | ||
* Main (host) build for dev branch: | * Main (host) build for dev branch: K:\qt\android\host | ||
* Visual Studio 2022 (MSVC) | * Visual Studio 2022 (MSVC) | ||
* Don't have perl in path as it can cause hard to understand build failures | * Don't have perl in path as it can cause hard to understand build failures | ||
* Have cmake in path | * Have cmake in path | ||
== Setting up | == Setting up Android SDK/NDK and JAVA == | ||
# Install Qt Creator with Android option | # Install Qt Creator with Android option using Qt Maintenance Tool | ||
# In Creator preferences, install Adoptium JDK (C:\Program Files\Eclipse Adoptium\jdk-17.0.10.7-hotspot) | # In Creator preferences, install Adoptium JDK (C:\Program Files\Eclipse Adoptium\jdk-17.0.10.7-hotspot) | ||
# Android SDK location: C:\ | # Android SDK location: C:\Utils\Android | ||
# Select Android NDK 26.1.10909125 and make default | # Select Android NDK 26.1.10909125 and make default | ||
# Oppenssl location: C:\ | # Oppenssl location: C:\Utils\Android\android_openssl | ||
# Verify Android settings: | # Verify Android settings: | ||
[[File:Android settings 26.png]] | [[File:Android settings 26.png]] | ||
Line 23: | Line 23: | ||
[[File:Android Emulator.png]] | [[File:Android Emulator.png]] | ||
== | == Install MINGW == | ||
Run provisioning script from "K:\qt\android\qt6\coin\provisioning\common\windows\install-mingw.ps1" as administrator. This installs MINGW into C:\MINGW_PATH. | |||
== Creating Qt Host Build == | |||
Follow steps in https://doc.qt.io/qt-6/android-building.html to create a host build. | |||
Clone Qt source code | |||
K:\qt\Android> git clone <nowiki>git://code.qt.io/qt/qt5.git</nowiki> qt6 | |||
Initialize Qt submodules and configure the host build | |||
K:\qt\Android\host> ..\qt6\configure -developer-build -nomake tests -nomake examples -submodules qtmultimedia -init-submodules -codereview-username <gerrit username> | |||
Build the host build | |||
K:\qt\Android\host> cmake --build . --target host_tools --parallel | |||
== Building Qt for Android on Windows == | |||
This build setup works with my Samsung Galaxy S6 tablet | |||
Configure Qt | Enable the MINGW compiler suite | ||
set MINGW_ROOT=C:\MINGW_PATH\mingw64\bin | |||
set PATH=%MINGW_ROOT%;%PATH% | |||
Configure Qt for cross compile with Android using the host host build from K:\qt\android\host\qtbase. | |||
K:\qt\Android\android> ..\qt6\configure -debug -developer-build -qt-host-path K:\qt\android\host\qtbase -android-abis arm64-v8a -android-sdk C:\utils\android\ -android-ndk C:\utils\android\ndk\26.1.10909125\ -submodules qtmultimedia | |||
-nomake tests -nomake examples && ninja.exe | |||
Build | |||
K:\qt\Android\android> ninja | |||
== Configure QtMultimedia module for cross compiling with Android == | |||
When working with QtMultimedia, it is convenient to configure a separate build just for this submodule. This makes configuring and rebuilding faster as long as we only touch code in this submodule. | |||
K:\qt\android\qtmultimedia> ..\android\qtbase\bin\qt-configure-module.bat ..\qt6\qtmultimedia -- -DQT_BUILD_TESTS=ON -DQT_BUILD_EXAMPLES=ON -DQT_BUILD_TESTS_BY_DEFAULT=OFF -DQT_BUILD_EXAMPLES_BY_DEFAULT=OFF -DQT_BUILD_EXAMPLES_AS_EXTERNAL=OFF | |||
== Importing Qt Multimedia build into QtCreator == | == Importing Qt Multimedia build into QtCreator == | ||
Line 36: | Line 56: | ||
# Open QtMultimedia CMakeLists.txt from D:\qt\qt6\qtmultimedia | # Open QtMultimedia CMakeLists.txt from D:\qt\qt6\qtmultimedia | ||
# Deselect all kits | # Deselect all kits | ||
# Import build from | # Import build from K:\qt\android\qtmultimedia | ||
#* This creates a Android Qt 6. | #* This creates a Android Qt 6.9.0 (android) Clang arm64-v8a | ||
#* Configure | #* Press 'Configure' button | ||
# | # Connect the Android device and go to Edit->Preferences->Devices, select Android tab, and make sure that configuration does not show any errors. | ||
# Select the project to build, and make sure the correct Android device is selected[[File:Image.png|thumb]] | |||
== Building FFmpeg for Android == | |||
See [[QtMultimedia_on_Android]] |
Latest revision as of 22:23, 11 August 2024
About this page
On this page, I describe how I build Qt for my Android device, which is a Samsung Galaxy S6. I work primarily with Qt Multimedia. I therefore need a build setup that makes it easy to debug, run tests, and examples from within an IDE without spending too much time on reconfiguring and rebuilding all of Qt. This tutorial follows the steps from the official Qt documentation at Qt for Android - Building from Source | Qt 6.7. In addition, I show how to configure Qt as a separate submodule to reduce the need for reconfiguring and rebuilding all of Qt.
My build setup
- OS: Windows 11 with dev drive mounted on K: (Using a dev drive makes builds faster when using Windows Defender antivirus)
- Qt source tree: K:\qt\android\qt6
- Build directory main Android build: K:\qt\android\android
- Main (host) build for dev branch: K:\qt\android\host
- Visual Studio 2022 (MSVC)
- Don't have perl in path as it can cause hard to understand build failures
- Have cmake in path
Setting up Android SDK/NDK and JAVA
- Install Qt Creator with Android option using Qt Maintenance Tool
- In Creator preferences, install Adoptium JDK (C:\Program Files\Eclipse Adoptium\jdk-17.0.10.7-hotspot)
- Android SDK location: C:\Utils\Android
- Select Android NDK 26.1.10909125 and make default
- Oppenssl location: C:\Utils\Android\android_openssl
- Verify Android settings:
- Add Android device for ABI x86_64, OS Version 13.0 ("Tiramisu") (SDK 33)
Install MINGW
Run provisioning script from "K:\qt\android\qt6\coin\provisioning\common\windows\install-mingw.ps1" as administrator. This installs MINGW into C:\MINGW_PATH.
Creating Qt Host Build
Follow steps in https://doc.qt.io/qt-6/android-building.html to create a host build.
Clone Qt source code
K:\qt\Android> git clone git://code.qt.io/qt/qt5.git qt6
Initialize Qt submodules and configure the host build
K:\qt\Android\host> ..\qt6\configure -developer-build -nomake tests -nomake examples -submodules qtmultimedia -init-submodules -codereview-username <gerrit username>
Build the host build
K:\qt\Android\host> cmake --build . --target host_tools --parallel
Building Qt for Android on Windows
This build setup works with my Samsung Galaxy S6 tablet
Enable the MINGW compiler suite
set MINGW_ROOT=C:\MINGW_PATH\mingw64\bin set PATH=%MINGW_ROOT%;%PATH%
Configure Qt for cross compile with Android using the host host build from K:\qt\android\host\qtbase.
K:\qt\Android\android> ..\qt6\configure -debug -developer-build -qt-host-path K:\qt\android\host\qtbase -android-abis arm64-v8a -android-sdk C:\utils\android\ -android-ndk C:\utils\android\ndk\26.1.10909125\ -submodules qtmultimedia -nomake tests -nomake examples && ninja.exe
Build
K:\qt\Android\android> ninja
Configure QtMultimedia module for cross compiling with Android
When working with QtMultimedia, it is convenient to configure a separate build just for this submodule. This makes configuring and rebuilding faster as long as we only touch code in this submodule.
K:\qt\android\qtmultimedia> ..\android\qtbase\bin\qt-configure-module.bat ..\qt6\qtmultimedia -- -DQT_BUILD_TESTS=ON -DQT_BUILD_EXAMPLES=ON -DQT_BUILD_TESTS_BY_DEFAULT=OFF -DQT_BUILD_EXAMPLES_BY_DEFAULT=OFF -DQT_BUILD_EXAMPLES_AS_EXTERNAL=OFF
Importing Qt Multimedia build into QtCreator
- Open QtMultimedia CMakeLists.txt from D:\qt\qt6\qtmultimedia
- Deselect all kits
- Import build from K:\qt\android\qtmultimedia
- This creates a Android Qt 6.9.0 (android) Clang arm64-v8a
- Press 'Configure' button
- Connect the Android device and go to Edit->Preferences->Devices, select Android tab, and make sure that configuration does not show any errors.
- Select the project to build, and make sure the correct Android device is selected