Building qt-android on windows
Tested last time on branch 5.4 2015-01-22
Note, it is not currently possible to use Microsoft's compilers to build the Windows host tools for Qt Android.
Setting up a development environment
- Install the latest Perl:
Select Destination folder (we'll call this <PERL_ROOT>, and refer similarly to other install locations).
- Set up the MinGW toolchain.
One way to do this is to download a pre-built Qt package for MinGW, and then add it (e.g. C:\dev\Qt\Tools\mingw730_64\bin) to PATH. Another way is to install the latest MinGW-w64 from mingwbuilds:
Extract to <MINGW_BUILDS_ROOT> and add <MINGW_BUILDS_ROOT>32\bin to the front of your PATH.
- Install the latest JDK 7:
Add <JDK_ROOT> to PATH.
- Install Android NDK:
Extract to <ANDROID_NDK_PATH> If you have ndk9 installed update it to latest version cause it doesn't work any more.
- Install the latest Android SDK (tools only):
Run the Android SDK Manager and install the latest version of "SDK Platform", "Google APIs" and "build-tools" in <ANDROID_SDK_PATH>
- Open cmd.exe window and perform some checks:
Ensure "where gcc.exe" lists <MINGW_ROOT>.exe first (before <PERL_ROOT>.exe) Ensure "where mingw32-make.exe" lists <MINGW_ROOT>32-make.exe first. Ensure "where perl.exe" lists <PERL_ROOT>.exe first. Ensure "where javac.exe" lists <JDK_ROOT>first.
- Add some environment variables:
set "ANDROID_API_VERSION=android-21" set "ANDROID_SDK_ROOT=<ANDROID_SDK_PATH>" set "ANDROID_TARGET_ARCH=armeabi-v7a" set "ANDROID_BUILD_TOOLS_REVISION=21.1.2" set "ANDROID_NDK_PATH=<ANDROID_NDK_PATH>" set "ANDROID_TOOLCHAIN_VERSION=4.9"
And the path to NDK:
.. depending on which NDK you downloaded.
- Make the root folder for the Qt/Android build:
Make sure there are no spaces in this path and that it doesn't contain too many characters. I went for "C:"
mkdir C:cd C:
- Follow step 4 at http://wiki.qt.io/Qt5ForAndroidBuilding
configure.bat -developer-build -platform win32-g++ -opengl es2 -xplatform android-g++ -android-ndk ANDROID_NDK_PATH -android-sdk ANDROID_SDK_ROOT -opensource -confirm-license -nomake tests -nomake examples mingw32-make.exe -j<N>
..where <N> is the number of parallel jobs your system can optimally exploit. If you have trouble, remove the -j<N>, and try again.
- Follow steps 8..11 at http://wiki.qt.io/Qt5ForAndroidBuilding (replacing make with mingw32-make.exe)
You can also build Qt/Android from the MSYS shell- the one from mingw-builds that you already downloaded - following much the same procedure and using exactly the same software. This is currently left as an exercise for the reader.