Is there way to compile Qt5 programs, written with c++, to Ubuntu Touch?

I'm creating a program with Qt5 and C++, and I would like to compile my program for Ubuntu Touch Preview or Ubuntu desktop arm.

I'm running those systems on Nexus 7. I have found the right C++ compiler (arm-linux-gnueabihf-g++), but how can I get Qt5 working?


The easy way

You can use an experimental feature of the Ubuntu SDK Alpha. The beauty of it is that you don't need to cross-compile.

First connect to your device:

  1. Plug in your device to your computer's USB port
  2. Start Qt Creator
  3. Click on the devices tab
  4. Click the Enable button to enable developer mode
  5. Go to Tools > Ubuntu > Device > Enable > Cpp compiling on Ubuntu device (experimental)

Then start hacking:

  1. Open your app's project in Qt Creator
  2. Go to Build > Ubuntu > Build C++ project on Ubuntu device (experimental)

Building C++ Touch projects on the device

And off you go! :-)

If you like a challenge

You could conceivably compile the apps on the device by hand. You might want to try the following (untested) steps:

  1. SSH into your device running the Ubuntu Touch Developer Preview

  2. Install the required development packages. Depending on what you need, you might need to add packages to the list, but here's a first shot:

    sudo apt-get install qt5-default qtbase5-dev libqt5v8-5-dev qtdeclarative5-dev libqt5xmlpatterns5-dev qtscript5-dev qttools5-dev qt3d5-dev qtmultimedia5-dev libqt5svg5-dev qtdeclarative5-dev-tools qttools5-dev-tools qtlocation5-dev qtsensors5-dev qtpim5-dev qt-components-ubuntu

  3. Build your C++ app with your build system of choice (cmake, qmake, etc...)


There is another suggestion (third way, but hard):
1. get linaro toolchain for armhf
2. get libhybris and platform-api (from phablet-team at launchpad.net)
3. get dynamic libs from device (/lib/arm-linux-gnueabihf and /usr/lib/arm-linux-gnueabihf/)
4. patch mkspecs for qmake
5. compile
6. add <your_app>.desktop file to /usr/share/applications/
7. add lines to /usr/share/qml-phone-shell/Applications/applications.js (may be optional, I think)
8. push your app and resources
9. reboot shell or phone
10. Your got worked app! (I tested this!)


Extended instruction founded on previous answer. Keep in mind: this instruction describes Qt/Qml developing on PC for Ubuntu Touch without ssh connection with device and require cross-compile tool like linaro.

PART 1: making environment

  1. Get Ubuntu SDK
  2. Get toolchain: Linaro or wia sudo apt-get install gcc-arm-linux-gnueabihf install toolchain and it's dependencies.
  3. Get this two libs libhybris and platform-api plus Qt5 libs for armhf (can be obtained from device) or just download tarball with all libs (from tarball your need libs and headers, put them at /usr/arm-gnueabihf/lib and /usr/arm-gnueabihf/include).
  4. Get modified qmake config - unrar it in mkspecs (for example, mine at /usr/share/qt5/mkspecs/). Inside unrared directory - qmake.conf. If something missed on compiling - it's need to alter path variable in that file.
  5. For Qt Creator make new compiling profile: in Compiling and deployment settings, on tab Compiler - add new compiler (arm-linux-gnueabihf-gcc), on tab Tools - add new profile and specify Device type - General linux-device, Compiler - ones, that you are added Profile Qt - generic (I'm using not recompiled Qt!!!), Qt mkspec - linux-arm-gnueabihf-gcc. It's all you need for compiling. For debugging - it's need to be specify other params. And beside it, that's better recompile Qt from sources. But I'm lazy so)

PART 2: deploying app

  1. Wia adb push /data/ubuntu/<some_path> push app and resources. OS can find them at /<some_path>. Note, there are no /data/ubuntu part. That part is needed only by adb.
  2. Next, need to make <app_name>.desktop file:
    • adb root
    • adb shell
    • ubuntu_chroot shell - switch to bash on device
    • cd /usr/share/applications - go in folder with *.desktop files
    • Copy any of them and edit (with vi) for your app purpose (name, icon, path, e.t.c.)
  3. Next step, same as previous (you already in bash at device):
    edit file (with vi) /usr/share/qml-phone-shell/Applications/applications.js, add part for your app in file, same as other apps have in that file. It must be same as in <app_name>.desktop file
  4. Reboot shell (by killing qml-phone-shell process) or reboot phone (reboot -p)
  5. Now you can launch your app from Apps page!

Test example and original materials: EN instruction and RU instruction with links for downloads toolchain and essential libs.