Necessitas/Qt4Creator: Difference between revisions
No edit summary |
|||
Line 77: | Line 77: | ||
=== Specify the Qt Framework === | === Specify the Qt Framework === | ||
=== specify the Android toolchain === | |||
=== Specify the Android SDK and NDK === | === Specify the Android SDK and NDK === |
Revision as of 11:31, 3 July 2012
Introduction
The Necessitas QtCreator if the centerpiece of developing with Qt on Android. It allows you to write code in C++ without caring for all the complexity of deploying it as a shared library wrapped up into a Java Activity, creating an APK, sign it and deploy to the device.
If you have experience in Android development, you know that's a bit different from the Qt approach. The Necessitas QtCreator does everything for you!
Of course you could use any QtCreator with the Android Qt framwork, but you would get no integration.
Obtaining Necessitas' Qt Creator
download the binaries (Windows, Linux, MacOSX)
The simplest way is to download the Necessitas/InstallSDK. Install it for your development platform and enjoy! You don't have to do nothing more.
Compiling from sources
Only if you want to be on the bleeding edge and try out the latest changes and features, you can feel brave and build the latest release from git.
Please note that the build process is supported only for Linux.
These 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.
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 flavor of Linux should work.
Compiling the QtCreator is a long task and shall take time even on powerful hardware. It is suggested a modern CPU and as much RAM as you can. Expect much less than building the Qt framework, but still quite some time.
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!
To compile QtCreator 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 (minumum version 1.8)
The QtCreator build process requires the Qt framework in place. Do not get confused... you do not need the Android Qt framework nor Necessitas! What you need is a recent release of the Qt framework for linux! The easiest way is to grab the Nokia Qt SDK from http://qt.nokia.com/downloads, download wither the online or offline version, as you prefer, and install it on your machine. Just remember the path where you have installed it because you will need it soon.
Please note that a reasonable recent version of the Qt framework is required. At very least Qt 4.7.4, but probably Qt 4.8 will be mandatory soon.
Get the sources
The QtCreator sources for Necessitas are available from the official git repository at the following url: git://gitorious.org/~taipan/qt-creator/android-qt-creator.git
To clone the repository, the usual command is:
git clone git://gitorious.org/~taipan/qt-creator/android-qt-creator.git
You need internet access, of course. A new folder called android-qt-creator. This folder will contain the entire QtCreator sources 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.
Compile!
To compile QtCreator, you must first run qmake, then make. When running qmake, be sure to specify the full path to the Qt framework you are using. If you have installed the Nokia Qt SDK as suggested above, just remember the full path and add bin/qmake to it. So get into the sources folder:
cd android-qt-creator /full_path_to_installed_qt_framework/bin/qmake -r make -j3
(you have to replace 3 with the number of CPU or cores your PC have + 1)
This will take a while... So sit back, grab a coke, a pizza maybe... maybe a short shower if it's too hot, specially in summer time.
When it's done, go to the next paragraph: Setting up Qt Creator!
Setting up Qt Creator
If you have installed the Necessitas SDK everything should be already configured, but you might want to check your configuration if something is not working properly...
If you have conpiled from sources, you definitely need to setup your Qt Creator!
Before starting, make sure you have both ant and a Java JDK installed in your system. More details on this can be found on the Necessitas/InstallSDK page, since it differs for Windows, Linux and MacOSX.
Specify the Qt Framework
specify the Android toolchain
Specify the Android SDK and NDK
Specify the other paths
You will just need to set up the Qt in Path to the freshly installed Qt for Android Sdk, and to provide the android Sdk to use.
Previous step should have installed you Qt Creator for Android, you will find a shortcut on your desktop. Run Qt Creator for Android and click on Tools > Options, then jump to the Qt4 tab. Just add the qmake path from the Qt For Android Sdk (/opt/necessitas/Android/<qtversion>/bin/qmake by default). Give this Qt version a name (e.g. android-lighthouse-4.8.0).
Set Qt Path in Qt Creator Figure 1. Set Qt Path for Qt Creator to Qt Sdk for Android
Jump to the Android tab. Set the path to the Android sdk location, minimum required version for the sdk is android-sdk_r09 ([Setup Android SDK] or download & install instructions). Set the path to the Android ndk location, minimum required version for the sdk is android-ndk_r5 (download & install instructions). For a seamless debugging experience you should take a look at [Debugging Qt apps for Android]. Select the correct Android ndk toolchain version : arm-linux-androideabi-4.4.3. Provide the Ant location to Qt Creator (/usr/bin/ant should be the right one, see Ant Official Website to get more information about this java build tool).
Set Android Sdk, Ndk & Ant Path in Qt Creator Figure 2. Set Android Sdk, Ndk & Ant Path - With this view you can even manage the AVDs you created (AVD stands for Android Virtual Device)
Jump back to the Qt4 tab, select the version of Qt you added previously and build the gdb helpers, so that your debugging output will be clean and easily readable for Qt specific constructs. Click Apply & Ok and you are done, you can start using the awesome Qt Sdk for Android. You can now try: [How to write Qt apps for Android]