如何在Android系统上编译运行C/C++程序 [英] How to compile and run a C/C++ program on the Android system

查看:14
本文介绍了如何在Android系统上编译运行C/C++程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Q1) 我想在 android 模拟器上运行一个简单的 c 程序.我在我的机器上使用 windows xp os.我已经安装了 sdk, jdk, eclipse 用于 android 开发并成功在 AVD 上运行 android 应用程序.

Q1) I want to run a simple c program on android emulator.I am using windows xp os on my machine. I have installed sdk, jdk, eclipse for android development and succeeded running android application on AVD.

Q2) 我只需要知道有没有办法在 AVD 上运行 C 程序(没有任何 java).在我的机器上,我安装了 arm 并使用它编译了一个 C 程序.

Q2) I just need to know is there any way to run a C program(without any java) on AVD. On my machine I have installed arm and using that I have compiled a C program.

Q3) 我也想知道是否可以将编译后的二进制文件推送到 android 设备或 AVD 并使用 android 设备的终端或 AVD 运行?

Q3) I also want to know is it possible to push the compiled binary into android device or AVD and run using the terminal of the android device or AVD?

推荐答案

您可以使用 ARM 交叉编译器编译您的 C 程序:

You can compile your C programs with an ARM cross-compiler:

arm-linux-gnueabi-gcc -static -march=armv7-a test.c -o test

然后你可以将你编译好的二进制文件推送到某个地方(不要将它推送到SD卡中):

Then you can push your compiled binary file to somewhere (don't push it in to the SD card):

adb push test /data/local/tmp/test

这篇关于如何在Android系统上编译运行C/C++程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆