Installing a program on a ubuntu touch phone

I searched on the website but didn't found an answer. I heard a lot that developing an application with C, C++ or anything else. Is it really possible ?

What I mean : Imagine I develop a program in C++ using QT library, how can I make it work on ubuntu-touch ? is it possible ? If I want to develop a game using SDL, openGL, can I install it on the phone ?

I never found a single article talking about those cases, and how it can be done ?


Solution 1:

This is my example of the project file for a plain C++ application (also shows how to add Qt libraries). Ubuntu-Click is generated.

Was compatible with the Ubuntu SDK when I composed it (so, just open it in Ubuntu SDK, it is a normal project).

Replace untitled everywhere with your program name.

CMakeLists.txt (there are Qt libs that you don't need or need more of them):

project(com.ubuntu.untitled C CXX)
cmake_minimum_required(VERSION 2.8.9)
find_program(INTLTOOL_MERGE intltool-merge)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-permissive -pedantic -Wall -Wextra -fPIC")

# Standard install paths
include(GNUInstallDirs)

option(CLICK_MODE "Installs to a contained location" on)

set(APP_NAME untitled)
set(DESKTOP_FILE "${PROJECT_NAME}.desktop")
set(APP_HARDCODE untitled)
set(ICON_FILE untitled256.png)
set(EXEC "${APP_NAME}")
set(UBUNTU_MANIFEST_PATH "manifest.json.in" CACHE INTERNAL "Relative path to the manifest file")

if(CLICK_MODE)
    # Find out the architecture for package building
    # to determine the plugin's installation path
    execute_process(
        COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
        OUTPUT_VARIABLE ARCH_TRIPLET
        OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    set(CMAKE_INSTALL_PREFIX /)
    set(CMAKE_INSTALL_BINDIR /)
    set(DATA_DIR /)
    set(DESKTOP_DIR ${DATA_DIR})
    set(ICON ${ICON_FILE})
    set(BIN_DIR /lib/${ARCH_TRIPLET}/bin)

    execute_process(
      COMMAND dpkg-architecture -qDEB_HOST_ARCH
      OUTPUT_VARIABLE CLICK_ARCH
      OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)
    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json ${APP_NAME}.apparmor DESTINATION ${CMAKE_INSTALL_PREFIX})

    # make the click files visible in qtcreator
    file(GLOB CLICK_FILES
         RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
         *.json *.json.in *.apparmor)

    add_custom_target(com_ubuntu_untitled_CLICKFiles ALL SOURCES ${CLICK_FILES})
else(CLICK_MODE)
    set(DATA_DIR ${CMAKE_INSTALL_DATADIR}/${APP_NAME})
    set(ICON ${CMAKE_INSTALL_PREFIX}/${DATA_DIR}/${ICON_FILE})
    set(DESKTOP_DIR ${CMAKE_INSTALL_DATADIR}/applications)
endif(CLICK_MODE)

file(GLOB SRC_FILES
     RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
     *.png)
install(FILES ${SRC_FILES}
    DESTINATION ${DATA_DIR})

configure_file(${DESKTOP_FILE}.in.in ${DESKTOP_FILE}.in)

add_custom_target(${DESKTOP_FILE} ALL
    COMMENT "Merging translations into ${DESKTOP_FILE}..."
    COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${DESKTOP_FILE}.in ${DESKTOP_FILE}
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE}
    DESTINATION ${DESKTOP_DIR})

include(FindPkgConfig)
find_package(Qt5Core)
find_package(Qt5Widgets)

aux_source_directory(. SRC_LIST)
add_executable(${APP_NAME} ${SRC_LIST})

if(CLICK_MODE)
  install(TARGETS ${APP_NAME} DESTINATION ${BIN_DIR})
else()
  install(TARGETS ${APP_NAME} RUNTIME DESTINATION bin)
endif()

qt5_use_modules(${APP_NAME} Widgets)

com.ubuntu.untitled.desktop.in.in:

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=@EXEC@
Icon=@ICON@
_Name=Untitled
X-Ubuntu-Touch=true
X-Ubuntu-Default-Department-ID=accessories

manifest.json.in:

{
    "description": "Untitled application",
    "framework": "ubuntu-sdk-14.10",
    "architecture": "@CLICK_ARCH@",
    "hooks": {
        "untitled": {
            "apparmor": "untitled.apparmor",
            "desktop": "com.ubuntu.untitled.desktop"
        }
    },
    "icon": "untitled256.png",
    "maintainer": "None <[email protected]>",
    "name": "com.ubuntu.untitled",
    "title": "Untitled",
    "version": "0.0.0"
}

untitled.apparmor (ripped that from standard camera application, I think):

{
    "policy_groups": [
        "picture_files",
        "video_files",
        "camera",
        "audio",
        "video",
        "usermetrics",
        "content_exchange",
        "content_exchange_source",
        "location"
    ],
    "policy_version": 1.2,
    "read_path": [
        "@{PROC}/*/mounts",
        "/dev/disk/by-label/"
    ]
}

And an icon untitled256.png.

All composed from the ubuntu-terminal-app and camera-app (sources are on the launchpad).