我想在 Ubuntu touch 下在 Nexus 7 上测试一些 C 代码。在平板电脑上安装 Ubuntu touch 之前,我有一些问题:
是否可以像在笔记本电脑上一样直接在平板电脑上编译(gcc?)并运行代码?
在 Ubuntu Touch 上,是否有命令行在笔记本电脑或台式计算机上工作的 shell?
答案是肯定的(对于这两个问题),但在 Nexus 7 (2013) 上测试代码之前,您需要在笔记本电脑/台式机上运行 Utopic (14.10) 才能访问最新的开发工具。
按照安装步骤操作(使用开发通道获取 14.10 映像)。
安装管理您的设备所需的软件包:
sudo apt-get install ubuntu-device-flash phablet-tools
Run Code Online (Sandbox Code Playgroud)安装SDK
sudo apt-get install ubuntu-sdk
Run Code Online (Sandbox Code Playgroud)连接您的设备并启用读写模式(使用 SDK):

将示例代码推送到您的设备 ( hello.c ):
$ adb push hello.c /home/phablet
1 KB/s (82 bytes in 0.041s)
Run Code Online (Sandbox Code Playgroud)启动 phablet shell 连接,安装gcc(libc6-devroot 密码为phablet)并在目标上编译代码:
sylvain@sylvain-ThinkPad-T430s:~$ phablet-shell
start: Job is already running: ssh
/home/sylvain/.ssh/known_hosts updated.
Original contents retained as /home/sylvain/.ssh/known_hosts.old
4 KB/s (200 bytes in 0.040s)
Warning: Permanently added '[localhost]:2222' (RSA) to the list of known hosts.
Welcome to Ubuntu Utopic Unicorn (development branch) (GNU/Linux 3.4.0-3-flo armv7l)
* Documentation: https://help.ubuntu.com/
Last login: Wed Jul 9 21:29:20 2014 from localhost.localdomain
phablet@ubuntu-phablet:~$ sudo apt-get update
[sudo] password for phablet:
[...]
phablet@ubuntu-phablet:~$ sudo apt-get install gcc libc6-dev
[...]
phablet@ubuntu-phablet:~$ gcc -Wall hello.c -o hello
phablet@ubuntu-phablet:~$ ls
Documents Downloads hello hello.c Music Pictures Videos
phablet@ubuntu-phablet:~$ ./hello
Hello, world!
phablet@ubuntu-phablet:~$
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
2682 次 |
| 最近记录: |