User:Joger: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Tags: Manual revert Visual edit
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
== My build setup ==
OS: Windows 11 with dev drive mounted on D: (Using a dev drive makes builds faster when using Windows Defender antivirus)


Qt source tree: D:\qt\qt6\
My name is Jøger Hansegård, and I am manager for one of Qt Group's platform teams. I contribute mainly to Qt Multimedia.


Build directory containing all builds: D:\qt\build\
This page contains references to tips and tricks for working efficiently with Qt Multimedia. Since my primary platform is Windows, the guides are focusing on how to build Qt Multimedia on a Windows system.


Main (host) build for dev branch: D:\qt\build\dev\
My build setup
 
* [[Building Qt Multimedia with FFmpeg]]
Visual Studio 2022 (MSVC)
* [[Building Qt Multimedia for Android]]
 
* [[Color Management]]
Don't have perl in path as it can cause hard to understand build failures
* [[User:Joger/Embedded|Embedded Linux]]
 
* [[user:Joger/FFmpeg|FFmpeg]]
Have cmake in path
 
== Developer setup for Qt Multimedia ==
 
=== Initializing Qt Repo for Qt 6 with necessary dependencies for QtMultimedia ===
This init-repository initializes the necessary Qt submodules for working with QtMultimedia. By only initializing the repository with the necessary modules, the main Qt build is faster than doing a full build.<blockquote>C:\Strawberry\perl\bin\perl init-repository --module-subset=qtbase,qtquick3d,qtdeclarative,qtsvg,qtshadertools,qtmultimedia,qtrepotools -f --codereview-username johanseg</blockquote>
 
=== Building FFmpeg on Windows ===
 
# Install 7-zip from provisioning: Run qt6\coin\provisioning\common\windows\install-sevenzip.ps1 as admin
#* Needed by provisioning script for FFmpeg to unzip downloaded FFmpeg
# Install msys2 from provisioning: Run qt6\coin\provisioning\common\windows\install-msys2.ps1 as admin
#* Needed by provisioning script for FFmpeg because FFmpeg requires tools from msys to configure
# Install FFmpeg from provisioning: Run qt6\coin\provisioning\common\windows\install-ffmpeg.ps1 as admin
#* Since I only need MSVC build, I edit the install-ffmpeg.ps1 first, to comment out unnecessary versions
#* This sets FFMPEG_DIR=C:\FFmpeg-n6.0\build\msvc\installed\
 
=== Configure Qt main build ===
I build Qt as stand-alone module to make builds run faster when working in QtMultimedia. But first, we need to build the necessary dependencies. I do this from command line with D:\qt\build\dev as current directory.<blockquote>..\..\qt6\configure.bat -debug -developer-build -submodules QtMultimedia -nomake tests -nomake examples -- -DFFMPEG_DIR=C:\FFmpeg-n6.0\build\msvc\installed --fresh & ninja</blockquote>I work almost exclusively using debug builds. If you need a release build, configure the release build in a separate build directory. This is a developer build, and we can use D:\qt\build\dev\qtbase\ as CMAKE_PREFIX_PATH when developing other Qt modules. By configuring this way, QtMultimedia is built, which is not strictly necessary since I develop QtMultimedia in a separate build tree, but it is an easy way to make sure all QtMultimedia dependencies are built.
 
=== Configure Qt multimedia ===
I configure QtMultimedia using a CMakeUserPresets.json file that is located in D:\qt\qt6\qtmultimedia instead of using a configure script. This way, I can open the D:\qt\qt6\qtmultimedia as a folder in Visual Studio and configure it from there.
 
The benefit of using CMakeUserPresets.json is that Visual Studio knows how to debug the tests and examples. I have not found a way that allows Visual Studio to use an existing CMakeCache as a starting point.
 
<code>
{
    "version": 5,
    "configurePresets": [
        {
            "name": "msvc-64",
            "hidden": true,
            "condition": {
                "type": "equals",
                "lhs": "${hostSystemName}",
                "rhs": "Windows"
            },
            "generator": "Ninja",
            "cacheVariables": {
                "CMAKE_CXX_COMPILER": "cl.exe",
                "CMAKE_C_COMPILER": "cl.exe"
            },
            "toolset": {
                "value": "v143,host=x64",
                "strategy": "external"
            },
            "architecture": {
                "value": "x64",
                "strategy": "external"
            }
        },
        {
            "name": "Debug",
            "hidden": true,
            "cacheVariables": {
                "CMAKE_BUILD_TYPE": "Debug"
            }
        },
        {
            "name": "qt6-dev-base",
            "hidden": true,
            "cacheVariables": {
                "FEATURE_developer_build": true,
                "BUILD_qttools": false,
                "BUILD_qtdoc": false,
                "BUILD_qttranslations": false,
                "QT_BUILD_EXAMPLES": false,
                "QT_BUILD_EXAMPLES_BY_DEFAULT": false,
                "QT_BUILD_EXAMPLES_AS_EXTERNAL": false,
                "QT_BUILD_TESTS": false,
                "QT_BUILD_TESTS_BY_DEFAULT": false
            },
            "environment": {
                "PATH": "D:/qt/build/dev/qtbase/bin;$penv{PATH}"
            }
        },
        {
            "name": "qt6-dev-debug",
            "hidden": true,
            "inherits": [
                "qt6-dev-base",
                "msvc-64",
                "Debug"
            ],
            "cacheVariables": {
                "CMAKE_PREFIX_PATH": "D:/qt/build/dev/qtbase/"
            },
            "environment": {
                "PATH": "D:/qt/build/dev/qtbase/bin;$penv{PATH}"
            }
        },
        {
            "name": "QtMultimedia",
            "inherits": "qt6-dev-debug",
            "binaryDir": "D:/qt/build/qtmultimedia/",
            "cacheVariables": {
                "QT_BUILD_EXAMPLES": true,
                "QT_BUILD_EXAMPLES_BY_DEFAULT": true,
                "QT_BUILD_TESTS": true,
                "QT_BUILD_TESTS_BY_DEFAULT": true,
                "QT_BUILD_EXAMPLES_AS_EXTERNAL": false,
                "QT_BUILD_MANUAL_TESTS": false,
                "QT_DEPLOY_FFMPEG": true,
                "FEATURE_ffmpeg": true,
                "FFMPEG_DIR": "C:\\ffmpeg-n6.0\\build\\msvc\\installed"
            }
        }
    ],
    "buildPresets": [
        {
            "name": "Build-Qt-Multimedia-MSVC-Debug-64",
            "displayName": "Build Qt Multimedia MSVC Debug 64",
            "configurePreset": "QtMultimedia"
        }
    ]
}
</code>
== Setting up Qt Creator for Android ==
 
# Install Qt Creator with Android option
# In Creator preferences, install Adoptium JDK (C:\Program Files\Eclipse Adoptium\jdk-17.0.10.7-hotspot)
# Android SDK location: C:\dev\android
# Select Android NDK 26.1.10909125 and make default
# Oppenssl location: C:\dev\android\android_openssl
# Verify Android settings:
[[File:Android settings 26.png]]
# Add Android device for ABI x86_64, OS Version 13.0 ("Tiramisu") (SDK 33)
[[File:Android Emulator.png]]
 
== Building Qt for Android on Windows ==
Main build root Android: D:\qt\build\android
 
 
 
Configure Qt for Android in build root using host build<blockquote>cmake -DQT_BUILD_SUBMODULES=QtMultimedia -DQT_HOST_PATH=D:/qt/build/dev/qtbase -DQT_BUILD_TESTS_BY_DEFAULT=OFF -DQT_BUILD_TESTS=ON -DANDROID_PLATFORM=android-33 -DQT_USE_TARGET_ANDROID_BUILD_DIR=TRUE -DQT_QMAKE_TARGET_MKSPEC=android-clang -DANDROID_SDK_ROOT=C:/dev/android -DANDROID_NDK_ROOT=C:/dev/android/ndk/26.1.10909125 -DANDROID_ABI=x86_64 -DQT_BUILD_EXAMPLES=FALSE -DCMAKE_BUILD_TYPE=Debug -DINPUT_developer_build=yes --fresh -G Ninja D:/qt/qt6 & ninja</blockquote>Main build directory for Qt Multimedia on Android: D:\qt\build\androidmultimedia
 
Configure Qt Multimedia for Android <blockquote>cmake-DCMAKE_TOOLCHAIN_FILE=D:\qt\build\android\qtbase\lib\cmake\qt6\qt.toolchain.cmake -G Ninja  -DQT_USE_ORIGINAL_COMPILER=ON -DQT_BUILD_TESTS=ON -DQT_BUILD_TESTS_BY_DEFAULT=OFF D:/qt/qt6/qtmultimedia & ninja</blockquote>
 
== Importing Qt Multimedia build into QtCreator ==
 
# Open QtMultimedia CMakeLists.txt from D:\qt\qt6\qtmultimedia
# Deselect all kits
# Import build from D:\qt\build\androidmultimedia
#* This creates a Android Qt 6.8.0 (android) Clang x86_64 kit
#* Configure is run automatically again
# Select a test to be built (tst_qmediadevices) and choose a corresponding emulator in project build settings for Android kit
# Build target tst_qmediadevices
# Observe error message:
 
<blockquote>19:15:12: The process "C:\Program Files\CMake\bin\cmake.exe" exited normally.
 
19:15:12: Starting: "D:\qt\build\dev\qtbase\bin\androiddeployqt.exe" --input D:/qt/build/androidmultimedia/tests/auto/unit/multimedia/qmediadevices/android-tst_qmediadevices-deployment-settings.json --output D:/qt/build/androidmultimedia/tests/auto/unit/multimedia/qmediadevices/android-build --android-platform android-33 --jdk "C:/Program Files/Eclipse Adoptium/jdk-17.0.10.7-hotspot" --gradle
 
Cannot find application binary in build dir D:/qt/build/androidmultimedia/tests/auto/unit/multimedia/qmediadevices/android-build//libs/x86_64/libtst_qmediadevices_x86_64.so.
 
19:15:12: The process "D:\qt\build\dev\qtbase\bin\androiddeployqt.exe" exited with code 2.
 
Error while building/deploying project QtMultimedia (kit: Android Qt 6.8.0 (android) Clang x86_64)
 
When executing step "Build Android APK"
 
19:15:12: Elapsed time: 01:05.</blockquote>

Latest revision as of 16:06, 13 November 2024

My name is Jøger Hansegård, and I am manager for one of Qt Group's platform teams. I contribute mainly to Qt Multimedia.

This page contains references to tips and tricks for working efficiently with Qt Multimedia. Since my primary platform is Windows, the guides are focusing on how to build Qt Multimedia on a Windows system.

My build setup