Install Ubuntu on a smartphone/tablet ===================================== [1] http://developer.ubuntu.com/start/ubuntu-for-devices/installing-ubuntu-for-devices/ Compile SDL for a Ubuntu Touch device ===================================== 1/ First solution si to compile directly on the device, this is the usual way so won't be describe here. 2/ Second solution is to setup a cross-compilation environment. Assume, your host computer is a Ubuntu/Debian. Install an ARM toolchain: apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf Setup a "armhf chroot", using files that initially come from: [2] http://bazaar.launchpad.net/~mir-team/mir/development-branch/view/head $HOME/release/Release_SDL_UbuntuPhone/ ./SDL_hg : clone SDL ./SDL_mixer_hg : clone SDL mixer ./SDL_image_hg : clone SDL image ./SDL_ttf_hg : clone SDL ttf ./debian/control : comes from [2]. List of packages "vivid" ./tools/setup-partial-armhf-chroot.sh : comes from [2]. A few modifications (see "builddeps") ./cross-compile-chroot.sh : comes from [2]. Modified to compile SDL libs. ./cross-compile-chroot.sh -h : help ./cross-compile-chroot.sh -c : clean ./cross-compile-chroot.sh -u : create the chroot in "partial-armhf-chroot" + compile SDL ./cross-compile-chroot.sh -A : compile SDL_ttf ./cross-compile-chroot.sh -B : compile SDL_mixer ./cross-compile-chroot.sh -C : compile SDL_image If you setup and compile with "-u". Then -A, -B, -C. You should have libraries compiled in "$HOME/release/Release_SDL_UbuntuPhone/build". Remark: SDL needs to be compiled with "--enable-video-mir --enable-mir-shared". Check that the "configure" script has actually detected/enabled mir ! Currently, it fails because of a mir-client incorrect header: solution: in file ./partial-armhf-chroot/usr/include/mirclient/mir_toolkit/mir_surface.h: to comment: /* MirSurfaceVisibility mir_surface_get_visibility(MirSurface *surface); */ Remark: When a new ubuntu version comes (like "vivid"). To update the chroot, you need to fetch the latest file "./debian/control" from [2]. And also update the name ("vivid") in "./tools/setup-partial-armhf-chroot.sh". Compile you application for Ubuntu Touch ======================================== Add those variables to your current compilation environment: # Use the CHROOT ARMHF, for PNG and ZLIB CHROOT_ARMHF_PATH=$(HOME)/release/Release_SDL_UbuntuPhone/partial-armhf-chroot CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ LD=arm-linux-gnueabihf-gcc SDL_LIB=$(HOME)/release/Release_SDL_UbuntuPhone/build/lib SDL_INC=$(HOME)/release/Release_SDL_UbuntuPhone/build/include/SDL2/ LDFLAGS+= \ -L/usr/arm-linux-gnueabihf/lib \ -lm \ -lstdc++ \ -Wl,-rpath-link,$(CHROOT_ARMHF_PATH)/usr/lib/arm-linux-gnueabihf \ -Wl,-rpath-link,$(CHROOT_ARMHF_PATH)/lib/arm-linux-gnueabihf \ Of course, you need the usual -I$(SDL_INC) -lSDL2 etc. With this, you should be able to compile your executable application for UbuntuTouch arm. Setup a "click" package ======================= A directory (MyApplicationDirectory) like this: ./ *.png *.ttf *.jpg : your application resource files ./lib/arm-linux-gnueabihf/bin ./lib/arm-linux-gnueabihf/bin/main.out : compiled application ./lib/arm-linux-gnueabihf/ : SDL libraries + links. (copy the SDL libs with : "cp -d $SDL_DIR/${LIB}*.so* ./" to preserve links) ./lib/arm-linux-gnueabihf/libSDL2-2.0.so.0 -> libSDL2-2.0.so.0.4.0 ./lib/arm-linux-gnueabihf/libSDL2-2.0.so.0.2.1 ./lib/arm-linux-gnueabihf/libSDL2-2.0.so.0.4.0 ./lib/arm-linux-gnueabihf/libSDL2_image-2.0.so.0 -> libSDL2_image-2.0.so.0.0.0 ./lib/arm-linux-gnueabihf/libSDL2_image-2.0.so.0.0.0 ./lib/arm-linux-gnueabihf/libSDL2_image.so -> libSDL2_image-2.0.so.0.0.0 ./lib/arm-linux-gnueabihf/libSDL2_mixer-2.0.so.0 -> libSDL2_mixer-2.0.so.0.0.0 ./lib/arm-linux-gnueabihf/libSDL2_mixer-2.0.so.0.0.0 ./lib/arm-linux-gnueabihf/libSDL2_mixer.so -> libSDL2_mixer-2.0.so.0.0.0 ./lib/arm-linux-gnueabihf/libSDL2.so -> libSDL2-2.0.so.0.4.0 ./lib/arm-linux-gnueabihf/libSDL2_ttf-2.0.so.0 -> libSDL2_ttf-2.0.so.0.10.2 ./lib/arm-linux-gnueabihf/libSDL2_ttf-2.0.so.0.10.2 ./lib/arm-linux-gnueabihf/libSDL2_ttf.so -> libSDL2_ttf-2.0.so.0.10.2 ./manifest.json ./MyApplicationName.desktop ./MyApplicationName.json For those files (manifest, destop, json) see [3]: http://developer.ubuntu.com/publish/webapp/packaging-web-apps/ Build the click package: click build MyApplicationDirectory You should get a file like "./com.ubuntu.developer.${DeveloperName}.${AppLogicName}_${AppVersion}_armhf.click" Install the "click" package on the device ========================================= You need to set the tablet in developer mode. adb push $CLICK /home/phablet/Downloads/ adb shell "sudo -H -u phablet pkcon --allow-untrusted install-local /home/phablet/Downloads/$CLICK" Read/Write configuration file in your application ================================================= You might want to read/write configuration file in your device. Here's a begining of code // The application will have read/write access files in the standard XDG base directories. // Specifically: XDG_CONFIG_HOME/ // where is what is used in the "name" field of the click manifest. const char *app_home = NULL; char app_pkgname[128] = {}; const char *app_id = NULL; int i = 0; int len_app_pkgname = 0; int found = 0; buffer[0] = '\0'; // TODO : XDG_CONFIG_HOME does not work -> use XDG_RUNTIME_DIR app_home = getenv("XDG_RUNTIME_DIR"); // env : APP_ID=com.ubuntu.developer.myname.myapp_myapp_1.00 app_id = getenv("APP_ID"); if (app_home == NULL || app_id == NULL) { return; } // Remove the first '_' to get the APP_PKGNAME strncpy(app_pkgname, app_id, sizeof (app_pkgname) - 1); len_app_pkgname = strlen(app_pkgname); for (i = 0; i < len_app_pkgname; i++) { if (app_pkgname[i] == '_') { app_pkgname[i] = '\0'; found = 1; break; } } if (! found) { return; } // Build the path snprintf(buffer, len - 1, "%s/confined/%s/", app_home, app_pkgname); ... Links ===== [1] http://developer.ubuntu.com/start/ubuntu-for-devices/installing-ubuntu-for-devices/ [2] http://bazaar.launchpad.net/~mir-team/mir/development-branch/view/head [3] http://developer.ubuntu.com/publish/webapp/packaging-web-apps/