Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

Building qt-android on windows: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(10 intermediate revisions by 4 users not shown)
Line 3: Line 3:
Note, it is not currently possible to use Microsoft's compilers to build the Windows host tools for Qt Android.
Note, it is not currently possible to use Microsoft's compilers to build the Windows host tools for Qt Android.


== ——————— Configuration ——————— ==
== Setting up a development environment ==


* '''Install the latest Perl:'''<br />http://strawberryperl.com/<br />Select Destination folder (we'll call this &lt;PERL_ROOT&amp;gt;, and refer similarly to other install locations).
* '''Install the latest Perl:'''
http://strawberryperl.com/
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:
http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/32-bit/threads-win32/dwarf/x32-4.8.1-release-win32-dwarf-rev1.7z/download
Extract to <MINGW_BUILDS_ROOT> and add <MINGW_BUILDS_ROOT>32\bin to the '''front''' of your PATH.


* '''Install the latest mingwbuilds MSYS and external binaries (for git):'''<br />http://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/msys+7za+wget+svn+git+mercurial+cvs-rev13.7z/download<br />Extract this to &lt;MINGW_BUILDS_ROOT&amp;gt; (I use C:-buildsso I end up with C:-builds\msys
* '''Install the latest JDK 7:'''
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Add <JDK_ROOT> to PATH.


* '''Install the latest MinGW-w64 from mingwbuilds:'''<br />http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/32-bit/threads-win32/dwarf/x32-4.8.1-release-win32-dwarf-rev1.7z/download<br />extract to &lt;MINGW_BUILDS_ROOT&amp;gt; and add &lt;MINGW_BUILDS_ROOT&amp;gt;32\bin to the '''front''' of your PATH.
* '''Install Android NDK:'''
https://developer.android.com/tools/sdk/ndk/index.html
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 JDK 7:'''<br />http://www.oracle.com/technetwork/java/javase/downloads/index.html<br />Add &lt;JDK_ROOT&amp;gt;to PATH.
* '''Install the latest Android SDK (tools only):'''
http://developer.android.com/sdk/index.html
Run the Android SDK Manager and install the latest version of "SDK Platform", "Google APIs" and "build-tools" in <ANDROID_SDK_PATH>


* '''Install Android NDK:'''<br />https://developer.android.com/tools/sdk/ndk/index.html<br />Extract to &lt;ANDROID_NDK_PATH&amp;gt;<br />If you have ndk9 installed update it to latest version cause it doesn't work any more.
* '''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.


* '''Install the latest Android SDK (tools only):'''<br />http://developer.android.com/sdk/index.html<br />Run the Android SDK Manager and install the latest version of &quot;SDK Platform&amp;quot;, &quot;Google APIs&amp;quot; and &quot;build-tools&amp;quot; in &lt;ANDROID_SDK_PATH&amp;gt;
* '''Add some environment variables:'''
<code>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"</code>
And the path to NDK:
<code>set "ANDROID_NDK_HOST=windows-x86_64"</code>
or
<code>set "ANDROID_NDK_HOST=windows"</code>
.. depending on which NDK you downloaded.


* '''Open cmd.exe window and perform some checks:'''<br />Ensure &quot;where gcc.exe&amp;quot; lists &lt;MINGW_ROOT&amp;gt;.exe first (before &lt;PERL_ROOT&amp;gt;.exe)<br />Ensure &quot;where mingw32-make.exe&amp;quot; lists &lt;MINGW_ROOT&amp;gt;32-make.exe first.<br />Ensure &quot;where perl.exe&amp;quot; lists &lt;PERL_ROOT&amp;gt;.exe first.<br />Ensure &quot;where javac.exe&amp;quot; lists &lt;JDK_ROOT&amp;gt;first.
== Cloning ==


* '''Add some environment variables:'''<br />set &quot;ANDROID_API_VERSION=android-21&amp;quot;<br />set &quot;ANDROID_SDK_ROOT=&lt;ANDROID_SDK_PATH&amp;gt;&quot;<br />set &quot;ANDROID_TARGET_ARCH=armeabi-v7a&amp;quot;<br />set &quot;ANDROID_BUILD_TOOLS_REVISION=21.1.2&amp;quot;<br />set &quot;ANDROID_NDK_PATH=&lt;ANDROID_NDK_PATH&amp;gt;&quot;<br />set &quot;ANDROID_TOOLCHAIN_VERSION=4.9&amp;quot;<br />set &quot;ANDROID_NDK_HOST=windows-x86_64&amp;quot;<br />or<br />set &quot;ANDROID_NDK_HOST=windows&amp;quot;<br />.. 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:"
<code>mkdir C:cd C:</code>


== ——————— Cloning ——————— ==
* '''Follow step 4 at http://wiki.qt.io/Qt5ForAndroidBuilding'''


* '''Make the root folder for the Qt/Android build:'''<br />Make sure there are no spaces in this path and that it doesn't contain too many characters.<br />I went for &quot;C:&quot;<br /><code>mkdir C:cd C:</code>
== Build steps ==


* '''Follow step 4 at http://wiki.qt.io/Qt5ForAndroidBuilding'''
<code>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></code>


== ——————— Build steps ——————— ==
..where <N> is the number of parallel jobs your system can optimally exploit. If you have trouble, remove the -j<N>, and try again.


<code>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<br />mingw32-make.exe -j&amp;lt;N&amp;gt;</code>
* '''Follow steps 8..11 at http://wiki.qt.io/Qt5ForAndroidBuilding (replacing make with mingw32-make.exe)'''


..where &lt;N&amp;gt; is the number of parallel jobs your system can optimally exploit. If you have trouble, remove the <s>j&amp;lt;N&amp;gt;, and try again.
== Finally ==
<br />* '''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.
<br />h2. ——————— Finally ———————
<br />You can also build Qt/Android from the MSYS shell</s> 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.

Latest revision as of 10:35, 1 March 2019

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:
http://strawberryperl.com/

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:

http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/32-bit/threads-win32/dwarf/x32-4.8.1-release-win32-dwarf-rev1.7z/download

Extract to <MINGW_BUILDS_ROOT> and add <MINGW_BUILDS_ROOT>32\bin to the front of your PATH.

  • Install the latest JDK 7:
http://www.oracle.com/technetwork/java/javase/downloads/index.html

Add <JDK_ROOT> to PATH.

  • Install Android NDK:
https://developer.android.com/tools/sdk/ndk/index.html

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):
http://developer.android.com/sdk/index.html

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:

set "ANDROID_NDK_HOST=windows-x86_64"

or

set "ANDROID_NDK_HOST=windows"

.. depending on which NDK you downloaded.

Cloning

  • 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:

Build steps

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.

Finally

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.