android下的c程序
来源:互联网 发布:葡萄牙语翻译软件 编辑:程序博客网 时间:2024/06/05 05:19
http://blog.csdn.net/luoshengyang/article/details/6571210
1 源代码
derek@u10:~/ics/ics-4.0.4/external/hello$ ls
Android.mk hello.c
hello.c
#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#define DEVICE_NAME "/dev/hello"int main(int argc, char** argv){int fd = -1;int val = 0;fd = open(DEVICE_NAME, O_RDWR);if(fd == -1) {printf("Failed to open device %s.\n", DEVICE_NAME);return -1;}printf("Read original value:\n");read(fd, &val, sizeof(val));printf("%d.\n\n", val);val = 5;printf("Write value %d to %s.\n\n", val, DEVICE_NAME); write(fd, &val, sizeof(val));printf("Read the value again:\n"); read(fd, &val, sizeof(val)); printf("%d.\n\n", val);close(fd);return 0;}
Android.mk
LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE_TAGS := optionalLOCAL_MODULE := helloLOCAL_SRC_FILES := $(call all-subdir-c-files)include $(BUILD_EXECUTABLE)
2 编译
derek@u10:~/ics/ics-4.0.4/$ . ./build/envsetup.sh
derek@u10:~/ics/ics-4.0.4/$ mmm ./external/hello
derek@u10:~/ics/ics-4.0.4/$ make snod
3 运行虚拟机,测试bin文件
derek@u10:~/ics/ics-4.0.4$ adb shell# # cd /bincd: can't cd to /bin# helloRead original value:5.Write value 5 to /dev/hello.Read the value again:5.
- android下的c程序
- android 下的C 程序开发
- c 程序在android下的执行
- Android下运行c程序
- Android下运行c程序
- android运行C程序以及C程序在android下的编译
- Android环境下的HelloWorld命令行C程序
- C程序下的三子棋
- 如何在Android下运行C程序
- Android下开机自启动C程序
- c程序在Android下执行
- 可执行的android C 程序
- android下的几个程序
- android 编译C程序 在android下可执行
- 在Android系统源码目录下编译C程序的方法
- LINUX 下的C程序错误号
- 第一个linux下的C程序
- linux下的第一个c程序
- LFS7.3 安装过程
- 关于C#中程序当前目录的小随笔
- 选用CEVA DSP,展讯进入3G手机TD-SCDMA基带处理器开发
- 用Python实现QR二维码的生成
- FrameWork4.0的兼容问题 .
- android下的c程序
- 提取字串
- 微软应用架构指南系列文章翻译
- 重载2
- fedora18使用配置(学习笔记1)
- 瞄准下一代应用 CEVA继续深耕DSP IP市场
- 九度oj1431
- 程序员必读的书
- Android玉石短剑之GridView之精挑细选