参考网页:
@L_301_0@
编译环境:
ubuntu 16.04以上系统
主要思想:
配置snapcraft.yaml文件,配置中之处编译的工具,和编译源码的所在。下面是一个简单的snap app。
mkdir hello-wmy/
cd hello-wmy/
touch snapcraft.yaml
vim snapcraft.yaml:
name: hello-wmy
version: "0.1"
summary: orbbec first snap app
description: puts up a square
confinement: strict
build-packages: - gcc apps: hello-wmy: # FIXME: remove opengl-launch once base wrappers set LIBGL_DRIVERS_PATH command: hello-wmy # Many apps do this instead,but it requires e.g. 'after: [desktop-gtk2]',which makes the snap huge #command: desktop-launch $SNAP/bin/hellogl parts: hello-wmy: source: . plugin: cmake
vim CMakeLists.txt
PROJECT (HELLO)
SET(SRC_LIST hello-wmy.c)
ADD_EXECUTABLE(hello-wmy ${SRC_LIST})
install(TARGETS hello-wmy DESTINATION bin)
vim hell-wmy.c
#include <stdio.h>
void main()
{
printf("hello snaps.\n");
}
最好事先安装CMake:apt-get install cmake
最后执行:sudo snapcraft
生成hello-wmy_0.1_amd64.snap 应用。
然后安装这个snap app到本地:
sudo snap install hello-wmy_0.1_amd64.snap –dangerous
然后运行:hello-wmy 会出现打印:hello snaps。说明成功!
需要加入 –dangerous 配置,因为现在这个snap没有经过签名。
如果提示没有找到–dangerous这个配置,更新一下snapd这个工具包: apt-get install snapd