Category Archives: QT

Building QT 6.2.2 for Windows and Android

I downloaded QT 6.2.2, verified its checksum:

certutil -hashfile MD5

Building for Windows with MSVC2019

Configured QT for building in the system Command Prompt (but not in MSVC Developer Command Prompt) as follows:

CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
set "CMAKE_ROOT=E:\PFiles\cmake-3.21.3-windows-x86_64\bin"
set "NINJA_ROOT=E:\PFiles\ninja-win"
set "PERL_ROOT=E:\PFiles\Strawberry\perl\bin"
set PATH=E:\PFiles\Python35;%PATH%
rem Check if the tools are in PATH
where perl.exe
where python.exe
where cmake.exe
where ninja.exe
set "MY_INSTALL_PATH=E:\Qt\Qt6.2.2\windows"
set CL=/MP
configure.bat -prefix %MY_INSTALL_PATH% -DQT_NO_EXCEPTIONS=1 -debug-and-release -force-debug-info -platform win32-msvc -opensource -confirm-license ^
-opengl es2 -I "C:\Program Files\OpenSSL\include" -L "C:\Program Files\OpenSSL\lib"

Building QT 6.2 for Android on Windows

First I built QT 6.2 for Windows then I installed JDK8, CMake 3.21.3 and configured QT as follows:

set "CMAKE_ROOT=E:\PFiles\cmake-3.21.3-windows-x86_64\bin"
set "NINJA_ROOT=E:\PFiles\ninja-win"
set "JDK_ROOT=C:\Program Files\Java\jdk1.8.0_301\bin"
set "MINGW_ROOT=E:\PFiles\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin"
set "PERL_ROOT=E:\PFiles\Strawberry\perl\bin"
set PATH=E:\PFiles\Python35;%PATH%
rem Check if the tools are in PATH
where gcc
where mingw32-make.exe
where perl.exe
where javac.exe
where python.exe
where cmake.exe
where ninja.exe

set "ANDROID_SDK_ROOT=C:\Users\D-Ef\AppData\Local\Android\Sdk"
set "ANDROID_NDK_PATH=C:\Users\D-Ef\AppData\Local\Android\Sdk\ndk\21.3.6528147"
rem See qtbase\mkspecs\android-clang\qmake.conf
set "ANDROID_NDK_PLATFORM=android-23"
rem see %ANDROID_SDK_ROOT%\build-tools folder
set MY_INSTALL_PATH=E:\Qt\Qt6.2\android
set QT_HOST_PATH=E:\Qt\Qt6.2\windows

configure.bat -platform android-clang -prefix %MY_INSTALL_PATH% -android-sdk %ANDROID_SDK_ROOT% -android-ndk %ANDROID_NDK_PATH% -qt-host-path %QT_HOST_PATH% -android-abis x86_64 ^
  -DQT_NO_EXCEPTIONS=1 -release -force-debug-info -opensource -confirm-license

How I fixed “CMake configuration has no path to C++ compiler” in QT Creator

CMake did not work and there was a yellow triangle at the left side of MSVC2019 kit name:

I fixed this buy changing C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat with C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsx86_arm64.bat.


Using QML_ELEMENT with CMake

There is an example of using QML_ELEMENT in qt5\qtdeclarative\examples\quick\scenegraph\openglunderqml and qt_add_qml_module in CMake:

    URI OpenGLUnderQML
    VERSION 1.0
    QML_FILES main.qml
    RESOURCE_PREFIX /scenegraph/openglunderqml

In QML it imports the module:

import OpenGLUnderQML 1.0

Building QT 6.2 for Windows with MSVC2019

I cloned QT repository:

git clone --recursive --branch v6.2.0
cd qt5

Looks like the command below is not required:

./init-repository --module-subset=all

because it prints:

Will not reinitialize already initialized repository (use -f to force)!

QtPurchasing uses deprecated AIDL billing library

Looks like QtPurchasing uses deprecated AIDL billing library and people say that it crashes on some devices. See for more information. Probably they are going to update it in 5.15.7 and move it into examples in QT 6, so it is not clear exactly what will happen with it, we probably better wait QT 5.15.7 to be released.


Invokable constructor in QT

In QT 5.15 I declare a class with an invokable constructor:

class TestClass : public QObject


    Q_INVOKABLE TestClass() {}


register its type:


‘Invalid UTF-8 code encountered.’ close reason with QWebSocket

I get close reason: ‘Invalid UTF-8 code encountered.’ (code=1007) with QWebSocket in the following scenario:

  • I connect to Binance stream wss:// with QWebSocket::open.
  • Successfully receive messages for some time period (a few hours).
  • Binance disconnects me when its servers load increases (because I have low-priority API) and I get close reason code=1000 that indicates a normal closure.
  • Try to reconnect multiple times by calling QWebSocket::open again, but Binance closes the connection with close reason ‘Invalid UTF-8 code encountered.’ (code=1007) that indicates that an endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [RFC3629] data within a text message).
  • Restart the application manually and connect successfully.

The difficulty of reproducing the bug is that Binance disconnects me rarely (once a day, for example) and experimentation with disconnecting the network cable from my machine does not have this effect, after I connect the cable back, QWebSocker reconnects successfully. When I disconnect the network cable I get Error: ‘Unknown error’ (code=-1), Close reason: ” (code=1000).


Built my QT app for Android with API level 30 (Android 11)

New Android App Bundle and target API level requirements in 2021:

Starting August 2021, new apps will be required to target API level 30 (Android 11) and use the Android App Bundle publishing format. Starting November 2021, all app updates will be required to target API level 30 (Android 11). Apps with a download size of more than 150 MB are now supported by Play Asset Delivery and Play Feature Delivery.

I updated the manifest manually as follows:

<?xml version="1.0"?>
<manifest package="net.geographx.LinesGame" xmlns:android="" android:versionName="2.5.30" android:versionCode="161" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30"/>

My QT Android app periodically crashes at android::RefBase::incStrong(void const*)

The call stack is:

  #00  pc 00000000000097a8  /system/lib/ (android::RefBase::incStrong(void const*) const+4)
  #00  pc 0000000000022145  /vendor/lib/
  #00  pc 000000000000ab79  /vendor/lib/ (KEGLGetDrawableParameters+252)
  #00  pc 0000000000041c53  /vendor/lib/egl/
  #00  pc 000000000001663d  /vendor/lib/egl/
  #00  pc 0000000000016b01  /vendor/lib/egl/ (glClear+440)
  #00  pc 000000000008acaf  /data/app/net.geographx.LinesGame-9_pUex92-tGEqE4iIbRCCw==/lib/arm/ (LinesGame::Squircle::beforeRendering()+270)
  #00  pc 000000000017d5b9  /data/app/net.geographx.LinesGame-9_pUex92-tGEqE4iIbRCCw==/lib/arm/
  #00  pc 0000000000176f4d  /data/app/net.geographx.LinesGame-9_pUex92-tGEqE4iIbRCCw==/lib/arm/ (QQuickWindowPrivate::renderSceneGraph(QSize const&, QSize const&)+172)

It is a QT bug that is not fixed yet.

Also my app crashes at the destructor of std::thread and this also a QT bug that is not fixed yet.