The Android Java SDK is nice and all, but what if you want to run some C service or code? Well, it turns out that this isn't exactly difficult. You can compile an application using a standard Linux cross-compiler, install it and run your programs from the shell.
You will need a cross-compiler (make sure you get the ARM GNU/Linux target). Then you can just create your program, compile, and upload to the device:
$ arm-none-linux-gnueabi-gcc -static hello.c -o hello$ adb push hello/hello data/hello
You can then simply run you application:
$ adb shell data/hello
Hello, Android!
Now of course, this doesn't at all explain how to tie into the graphics or the rest of the system, but that is left as an exercise for the reader ;)
本文介绍如何使用标准Linux交叉编译器为Android设备编译并运行C程序。首先需要获取针对ARMGNU/Linux目标的交叉编译器,然后创建、编译程序,并通过adb工具将其部署到Android设备上进行执行。
827

被折叠的 条评论
为什么被折叠?



