Jump to content

Necessitas/CompileQtFramework

From KDE Community Wiki

Foreword

This instructions are tailored for Linux, Ubuntu linux 12.04. Any Linux distribution which is reasonably updated should work anyway. There are some minimum GLIBC/GCC requirements, but anything updated at least at 01/2012 should not have any problems, provided that you fullfill all the requirements either by installing you distro packets or from sources. Ubuntu 12.04 do include all the requirements in the default repositories.

It is also possible to compile the Qt framework on Windows and MacOSX, but this Wiki page at the moment will not cover it.

Requirements

First of all, you need a working Linux installation. On this Wiki page Ubuntu 12.04 will be used as a reference, please note that any flavour of Linux should work.

Hardware Requirements

Compiling the Qt framework is a big task and shall take a long time even on powerfull hardware. It is suggested a modern CPU and as much RAM as you can. Expect a few hours of compilation on a 2.4Ghz dual-core Intel CPU with 3gb of RAM.

Make sure you have at least 20gb of free hard-disk space because of all the requirements and compile time space. Since this is a work-in-progress, the build tree will not be cleaned after the build is complete. So be wise, and increase that filesystem!

System Software Requirements

To compile the Qt framework you don't need all the usual dependency of Necessitas. But make sure your distribution has all the usual build tools. On Ubuntu, you want to make sure that the following packages are installed (use the package manager):

  • build-essential
  • git

It might be time to install also these packages, which are required for Necessitas SDK and not for building Qt directly:

  • OpenJDK
  • ant (minimum version 1.8)

Android specific Requirements

The Qt framework build process requires the Android NDK. While any Android NDK (>= r05) should be fine, since Necessitas requires Android NDK r06 it is advisable, at this point, to install this specific version. EDIT 10/21/12: It appears the Necessitas installer installs Android NDK r8b.

In case you don't have it, it's a good time now to grab the Necessitas SDK and install it: it will download and install for you both the proper Android NDK and SDK which will be later required to use the Qt framework you are going to build.

First download Necessitas SDK from https://sourceforge.net/projects/necessitas/files/, then make it executable and install:

chmod +x necessitas-x.y-online-sdk-installer-linux
./necessitas-x.y-online-sdk-installer-linux

Make sure you select Android SDK and Android NDK, and, after the installation is done, note down the respective paths, which are located under the folder where you installed the Necessitas SDK.

Anyway, if you want to download and install the Android SDK and NDK yourself, please note that the minimum required version of the SDK is r09 and for the NDK is r5.

Get ready and start!

Get the sources

The Qt framework for Necessitas is available from the official git repository at the following url: .

To clone the repository, the usual command is:

git clone git://anongit.kde.org/android-qt.git

You need internet access, of course. A new folder called android-qt. This folder will contain the entire Qt framework both before and after the build, so place it where you have plenty of free disk space and where you plan to install the framework. Branch select

You should make sure your have selected the branch you want to build. Just type:

git branch

to see all the available branches and:

git checkout branch-name

to sync your source tree to that specific branch. The branch names should be self-explanatory.

Compile!

Get into the just cloned repository:

cd android-qt

Start the build process, by using the provided androidconfigbuild.sh script to configure and build the framework. You must specify the full absolute path to your Android NDK installation path:

./android/androidconfigbuild.sh -n --path to android NDK-- -q 1 -d 1

(so something like for example: "./android/androidconfigbuild.sh -n /home/android/necessitas/android-ndk/ -q 1 -d 1")

Sit back, grab a coffee, then a pizza, then some icd cream, then a nap, finally a shower. Sometime later, it will be ready. The previous command line will build, for the first time, your framework with debugging symbols. For further compilations, for example if you have updated the repo or changed something, the following command line will be enough:

./android/androidconfigbuild.sh -n --path to android NDK--

Now, what do i do?

Setup QtCreator

Good, if you followed so far you should have built a working Qt repository for Android. At this point you must open the QtCreator and add this new Qt version to the list of available Qt versions.

In order to use Necessitas, you should now compile the Qt Creator for Necessitas. Check Necessitas/Qt4Creator. Of course, you don't need to build the QtCreator but you can use the version you have previously installed as part of the Necessitas SDK. Just be aware that will not be the latest release, and you still need to reconfigure it to use this newly compiled framework.

If, for any reason, you don't plan to use the Necessitas QtCreator, the same configuration process do apply to any standard QtCreator release, but you will not be able to use the integrated build process for Android, you will just be able to create the .so file, then you will have to manage your own Android build process.

Push libraries

Of course to be able to use your new Qt framework you must also push it to the device (emulator or real doesn't matter), you cannot use Ministro. You must enable the Deploy local qt libs. So within QtCreator open the Projects tab, go to Android / Run tab, open Deploy Configurations, check Deploy local qt libs, check the picture here:


Adding other libraries

In order to install all the following libraries, make sure you put the sources outside the main Qt framework working folder. Clone the repositories at least one lever above it: for example, if you have the Qt framework under /home/myself/qt-android, put each of the following under /home/myself/android-qt-mobility and so on.

QtMobility

First of all, clone the git repository:

git clone git://anongit.kde.org/android-qt-mobility.git

Then build it with the following command lines:

cd android-qt-mobility
ANDROID_NDK_ROOT=~/necessitas/android-ndk ./configure -prefix ../android-qt -staticconfig android -qmake-exec ../android-qt/bin/qmake -modules "bearer location contacts versit messaging systeminfo serviceframework sensors gallery organizer feedback connectivity"

Just check the ../android-qt and the ndk path to make sure it points exactly to the Qt framework you have just compiled! You can also select the modules you need. Please note that other modules might not be supported yet on Android.

Final notes

Build and configuration options

androidconfigbuild.sh accepts the following parameters (you can see all options by adding -p to script parameters):

usage: ./androidconfigbuild.sh options
OPTIONS:
-p Shows this message
-c Clean qt
-q Qt build options
0 - don't configure qt (only compile) default
1 - configure qt and compile qt
-b Build qt
0 - don't build
1 - build
-s Install qt
0 - don't install
1 - install
-n NDK root. Default "/usr/local/android-ndk-r5b"
-o NDK host. Default "linux-x86"
-f NDK toolchain prefix. Default "arm-linux-androideabi"
-v NDK toolchain version. Default "4.4.3"
-a Target cpu architecture. Default "armeabi"
armeabi - tune for android arm v5
armeabi-v7a - tune for android arm v7
Optional name suffix: v5/v7
-h Shared
0 - Build static version of qt
1 - Build shared version of qt
-x Exceptions options
0 - don't use exceptions (you won't be able to build qtcreator with such a qt though)
1 - use exceptions
Optional name suffix: Xc/Nx
-d Build debug qt
Optional name suffix: D/R/DaR
-r Build release qt
Optional name suffix: R/D/DaR
-m Modify install path according to passed in options (name suffixes applied in above listed  order). 
-i Install path. Default "/home/your-name/path/to/android-lighthouse"