Building qt-android on windows: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
=Building Qt/Android on Windows=
Tested last time on branch 5.4 2015-01-22
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.
Note, it is not currently possible to use Microsoft's compilers to build the Windows host tools for Qt Android.
 
==—————————— Configuration ——————————==
 
* '''Install the latest Perl:'''<br />http://strawberryperl.com/<br /> Select Destination folder (we’ll call this &lt;<span class="caps">PERL</span>_ROOT&gt;, and refer similarly to other install locations).


* '''Install the latest mingwbuilds <span class="caps">MSYS</span> 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;<span class="caps">MINGW</span>_BUILDS_ROOT&gt; (I use C:\mingw-builds\ so I end up with C:\mingw-builds\msys\)
== ——————— Configuration ——————— ==


* '''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;<span class="caps">MINGW</span>_BUILDS_ROOT&gt; and add &lt;<span class="caps">MINGW</span>_BUILDS_ROOT&gt;\mingw32\bin to the '''front''' of your <span class="caps">PATH</span>.
* '''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 <span class="caps">JDK</span> 7:'''<br />http://www.oracle.com/technetwork/java/javase/downloads/index.html<br /> Add &lt;<span class="caps">JDK</span>_ROOT&gt;\bin to <span class="caps">PATH</span>.
* '''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 Android <span class="caps">NDK</span>:'''<br />https://developer.android.com/tools/sdk/ndk/index.html<br /> Extract to &lt;<span class="caps">ANDROID</span>_NDK_PATH&gt;<br /> If you have ndk9 installed update it to latest version cause it doesn’t work any more.
* '''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 the latest Android <span class="caps">SDK</span> (tools only):'''<br />http://developer.android.com/sdk/index.html<br /> Run the Android <span class="caps">SDK</span> Manager and install the latest version of “<span class="caps">SDK</span> Platform”, “Google <span class="caps">API</span>s” and “build-tools” in &lt;<span class="caps">ANDROID</span>_SDK_PATH&gt;
* '''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.


* '''Open cmd.exe window and perform some checks:'''<br /> Ensure “where gcc.exe” lists &lt;<span class="caps">MINGW</span>_ROOT&gt;\bin\gcc.exe first (before &lt;<span class="caps">PERL</span>_ROOT&gt;\c\bin\gcc.exe)<br /> Ensure “where mingw32-make.exe” lists &lt;<span class="caps">MINGW</span>_ROOT&gt;\bin\mingw32-make.exe first.<br /> Ensure “where perl.exe” lists &lt;<span class="caps">PERL</span>_ROOT&gt;\perl\bin\perl.exe first.<br /> Ensure “where javac.exe” lists &lt;<span class="caps">JDK</span>_ROOT&gt;\bin first.
* '''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.


* '''Add some environment variables:'''<br /> set “<span class="caps">ANDROID</span>_API_VERSION=android-21”<br /> set “<span class="caps">ANDROID</span>_SDK_ROOT=&lt;<span class="caps">ANDROID</span>_SDK_PATH&gt;”<br /> set “<span class="caps">ANDROID</span>_TARGET_ARCH=armeabi-v7a”<br /> set “<span class="caps">ANDROID</span>_BUILD_TOOLS_REVISION=21.1.2”<br /> set “<span class="caps">ANDROID</span>_NDK_PATH=&lt;<span class="caps">ANDROID</span>_NDK_PATH&gt;”<br /> set “<span class="caps">ANDROID</span>_TOOLCHAIN_VERSION=4.9”<br /> set “<span class="caps">ANDROID</span>_NDK_HOST=windows-x86_64”<br /> or<br /> set “<span class="caps">ANDROID</span>_NDK_HOST=windows”<br /> .. depending on which <span class="caps">NDK</span> you downloaded.
* '''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;


==—————————— Cloning ——————————==
* '''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.


* '''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 “C:\work\build”<br />
* '''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.


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


==—————————— Build steps ——————————==
* '''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>


..where &lt;N&gt; is the number of parallel jobs your system can optimally exploit. If you have trouble, remove the -j&lt;N&gt;, and try again.
* '''Follow step 4 at http://wiki.qt.io/Qt5ForAndroidBuilding'''


* '''Follow steps 8..11 at [[Qt5ForAndroidBuilding|http://wiki.qt.io/Qt5ForAndroidBuilding]] (replacing make with mingw32-make.exe)'''
== ——————— Build steps ——————— ==


==—————————— Finally ——————————==
<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>


You can also build Qt/Android from the <span class="caps">MSYS</span> 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.
..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.
<br />* '''Follow steps 8..11 at http://wiki.qt.io/Qt5ForAndroidBuilding (replacing make with mingw32-make.exe)'''
<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.

Revision as of 12:47, 23 February 2015

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.

——————— Configuration ———————

  • Install the latest Perl:
    http://strawberryperl.com/
    Select Destination folder (we'll call this <PERL_ROOT&gt;, and refer similarly to other install locations).
  • 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&quot;, "Google APIs&quot; and "build-tools&quot; in <ANDROID_SDK_PATH&gt;
  • Open cmd.exe window and perform some checks:
    Ensure "where gcc.exe&quot; lists <MINGW_ROOT&gt;.exe first (before <PERL_ROOT&gt;.exe)
    Ensure "where mingw32-make.exe&quot; lists <MINGW_ROOT&gt;32-make.exe first.
    Ensure "where perl.exe&quot; lists <PERL_ROOT&gt;.exe first.
    Ensure "where javac.exe&quot; lists <JDK_ROOT&gt;first.
  • Add some environment variables:
    set "ANDROID_API_VERSION=android-21&quot;
    set "ANDROID_SDK_ROOT=<ANDROID_SDK_PATH&gt;"
    set "ANDROID_TARGET_ARCH=armeabi-v7a&quot;
    set "ANDROID_BUILD_TOOLS_REVISION=21.1.2&quot;
    set "ANDROID_NDK_PATH=<ANDROID_NDK_PATH&gt;"
    set "ANDROID_TOOLCHAIN_VERSION=4.9&quot;
    set "ANDROID_NDK_HOST=windows-x86_64&quot;
    or
    set "ANDROID_NDK_HOST=windows&quot;
    .. 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<br />mingw32-make.exe -j&amp;lt;N&amp;gt;

..where <N&gt; is the number of parallel jobs your system can optimally exploit. If you have trouble, remove the j&lt;N&gt;, and try again.
* Follow steps 8..11 at http://wiki.qt.io/Qt5ForAndroidBuilding (replacing make with mingw32-make.exe)
h2. ——————— 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.