打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
android交叉编译c程序

android交叉编译c程序



0人收藏此文章,


发表于2小时前(2013-07-29 11:38) ,
已有23次阅读 ,共0个评论

1.交叉编译工具

arm-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

2.解压

tar -xavf arm-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 -C /home/snail/bin

3.配置

gedit ~/.bashrc

在文件末尾添加

 export PATH=~/bin/arm-2012.03/bin/:$PATH

4.测试

arm-none-linux-gnueabi-gcc -v
 

5.编写helloworld.c

#include <stdio.h>  
int main()  
{  
    printf(“helloworld!\n”);  
    return 0;  
}  

6.编译

 arm-none-linux-gnueabi-gcc -o hello helloworld.c -static        (在这我说下,我的环境是Ubuntu10.04   64位,后面的-static这个参数非常的重要)

7.查看

snail@ubuntu :~/work/android/cross-c/1.helloworld$ file helloworld
helloworld: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped

8.执行

adb push 1.txt sdc

ard/

D:\adb\adb>adb push C:\Users\Administrator\Desktop\helloworld bin

adb shell

# chmod 777 hello
chmod 777 hello
# ./hello
./hello
helloworld!
#

 

可能问题:

64位ubuntu无法使用32位编译器。出现:

error: arm-none-linux-gnueabi-gcc: No such file or directory   很多人出现该为题,我是添加-static参数解决了,如果你添加参数没有解决,那么试下下面的

解决:

sudo apt-get install    libc6:i386   libgcc1:i386  gcc-4.6-base:i386  libstdc++5:i386  libstdc++6:i386

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
android上进行c/C 开发测试(转) - 奋进 - 博客园
建立ARM交叉编译环境 (arm
EABI技术编译器
【Zynq征文】Zynq交叉编译环境链的建立与C程序编写
为Android加入busybox工具
交叉编译gcc
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服