我在网站上搜索过,但没有找到答案。我听说很多人用 C、C++ 或其他语言开发应用程序。这真的可能吗?
我的意思是:假设我使用 QT 库在 C++ 中开发一个程序,如何让它在 ubuntu-touch 上运行?可能吗?如果我想使用 SDL、openGL 开发游戏,我可以将它安装在手机上吗?
我从来没有找到一篇讨论这些情况的文章,以及如何做到这一点?
答案1
这是我为普通 C++ 应用程序创建的项目文件示例(还展示了如何添加 Qt 库)。Ubuntu-Click 已生成。
当我编写它时,它与 Ubuntu SDK 兼容(因此,只需在 Ubuntu SDK 中打开它,它是一个普通项目)。
代替无标题到处都写上你的程序名称。
CMakeLists.txt(有些 Qt 库您不需要,或者需要更多):
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
清单.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"
}
无标题.apparmor(我认为是从标准相机应用程序中提取的):
{
"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/"
]
}
以及一个图标untitled256.png。
全部由ubuntu-终端应用程序和相机应用程序(来源位于启动板上)。