Native C applications for Android

本文介绍如何使用标准Linux交叉编译器为Android设备编译并运行C程序。首先需要获取针对ARMGNU/Linux目标的交叉编译器,然后创建、编译程序,并通过adb工具将其部署到Android设备上进行执行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 ;)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值