交叉编译静态C的hello world为Android使用手臂的Linux gnueabi-GCC [英] Cross compiling static C hello world for Android using arm-linux-gnueabi-gcc

查看:172
本文介绍了交叉编译静态C的hello world为Android使用手臂的Linux gnueabi-GCC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用臂的Linux gnueabi - 海湾合作委员会,而不是使用NDK的独立工具链或codesourcery为此事建立一个静态的Hello World从C。

I want to build a static hello world from C using arm-linux-gnueabi-gcc as opposed to using the NDK standalone toolchain or Codesourcery for that matter.

在Ubuntu的...

In Ubuntu...

我也做了以下内容:

sudo apt-get install gcc-arm-linux-gnueabi

我创造了这样一个hi.c:

I created a hi.c like this:

#include <stdio.h>

int main(int argc, char** argv) {
   printf("hello world\n");
   return 0;
}

我编这是这样的:

I have compiled it like this:

arm-linux-gnueabi-gcc -static hi.c -o hi 

我跑了它在这样一个仿真器:

I ran it on an emulator like this:

adb push hi /data/hi
adb shell /data/hi

不过,我得到这样的:

But, I get this:

[1]   Illegal instruction     /data/hi

有哪些步骤我忘了吗?根据以往的经验,这应该工作过,但我显然搞砸这件事。

What step have I forgot? Based on past experience this "should" have worked, but I obviously messed this up.

推荐答案

如果我这样做是Debian机(VM在我的情况)时,一切似乎都很好。我不知道什么时候不好做Ubuntu的相似。这可能是因为狮子座的建议,但我无法证实。这应该给你,虽然工作。

If I do this on a Debian machine (VM in my case), all seems well. I am not sure what when wrong with doing similar on ubuntu. It could be as Leo suggested, but I cannot confirm. This should work for you though.

http://www.cnx-software.com/2012/01/16/installing-emdebian-arm-cross-toolchain-in-debian/

有人加入此链接,但它不使用I在说明书中提到的工具链。离开它如果有人有兴趣。

Someone added this link, but it is not using the toolchain I mentioned in the description. Leaving it in case anyone is interested.

http://tariqzubairy.word$p$pss.com/2012/03/09/arm-binaries-static-library-for-android/

这篇关于交叉编译静态C的hello world为Android使用手臂的Linux gnueabi-GCC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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