Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6507404
  • 博文数量: 1159
  • 博客积分: 12444
  • 博客等级: 上将
  • 技术积分: 12570
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-13 21:34
文章分类

全部博文(1159)

文章存档

2016年(126)

2015年(350)

2014年(56)

2013年(91)

2012年(182)

2011年(193)

2010年(138)

2009年(23)

分类: C/C++

2015-10-21 11:14:43

# export PATH=$PATH:/opt/android-on-linux/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/

# arm-linux-androideabi-gcc --sysroot=/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/ hello.c -o hello

# adb push hello /data/

# adb shell

执行命令: 
chmod 700 /data/hello
/data/hello

+++++++++++++++++++++++++++++++++

# adb push hello /data/data/www/cgi-bin

宿主机浏览器:


如果成功的话, 可以看到浏览器上 Hello world!
++++++++++++++++++++++++++++++++++++++++++++++++
[root@localhost 桌面]# gedit readdisk.c


点击(此处)折叠或打开

  1. #include <stdio.h>
  2. #include <fcntl.h>

  3. int main()
  4. {
  5.     unsigned char buf[512];
  6.     int fd = open("/dev/blk/mmcblk1", O_RDWR);

  7.     printf("文件描述符%d", fd);
  8.     if (fd < 0) {        // printf("%d\n",errno);
  9.         return 0;
  10.     }
  11.     int num;
  12.     num = read(fd, buf, 512);
  13.     printf("读取字数%d", num);
  14.     printf("\n");
  15.     int i, j;
  16.     for (i = 0; i < 32; i++) {
  17.         for (j = 0; j < 16; j++)
  18.             printf("%02X ", buf[i * 16 + j]);
  19.         printf("\n");
  20.     }
  21.     printf("\n");
  22.     close(fd);
  23.     return 0;
  24. }

[root@localhost 桌面]# arm-linux-androideabi-gcc --sysroot=/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/ readdisk.c -o readdisk

++++++++++++++++++++++++++++++++++++
root@kltexx:/data # ./readdisk                                                                                                        
error: only position independent executables (PIE) are supported.

[root@localhost 桌面]# arm-linux-androideabi-gcc --sysroot=/opt/android-on-linux/android-ndk-r8e/platforms/android-14/arch-arm/ -pie -fPIE readdisk.c -o readdisk



阅读(2974) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~