Android的GCC SYSROOT和连接器 [英] Android gcc sysroot and linker

查看:816
本文介绍了Android的GCC SYSROOT和连接器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写一个简单的程序与Android NDK Linux构建在Ubuntu Linux 10.0.4。

  //没有包括!!!
诠释的main()
{
    诠释一个= 1,B = 2,C = -1;
    返回+ B + C - (A + B + C);}

当我运行这个bash脚本的GCC,

<$p$p><$c$c>bin='/media/sdb/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/$p$pbuilt/linux-x86/bin'
RM -r ./obj/*.*
    $斌/ ARM-Linux的androideabi-GCC -c ./main.c -o ./obj/main.o
    $斌/ ARM-Linux的androideabi-GCC ./obj/main.o -o ./obj/main.exe

GCC的输出提供了从 LD 消息(的 ARM-Linux的androideabi-LD ),它终止的 7(第二个逗号分隔的是ARM)信号。

这个简单的程序甚至不会编译在Linux上,请大家帮忙!


解决方案

我已经安装了静电工具链,在Ubuntu 12.4

 命令和apt-get安装GCC-ARM的Linux的gnueabi //安装这个工具链在arm-linux的-gnueabi-gcc的-static -o MAIN.EXE的main.c //这样编译二进制乌尔

亚行的Andr​​oid机和拷贝运行

  ./ MAIN.EXE

这部作品在我的Andr​​oid手机。

编辑:

10.04

  sudo的附加的apt-库PPA:Linaro的-维护/工具链
    sudo易于得到更新
    sudo易于得到安装gcc-臂Linux的gnueabi

EDIT2:
其静态编译在这里它不使用仿生code,它通过将其复制到ELF包括库。

如果您希望将动态编译或要取决于仿生code然后用

$ NDK /文档/ STANDALONE-TOOLCHAIN​​.html的https://android.googlesource.com/platform/ndk/+/master/docs/STANDALONE-TOOLCHAIN.html

I am compiling a simple program with the Android NDK Linux build on Ubuntu Linux 10.0.4.

//no includes!!!
int main()
{   
    int a = 1, b = 2, c = -1;
    return a + b + c - ( a + b + c);

}

When I run this bash script for gcc,

bin='/media/sdb/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin'
rm -r ./obj/*.* 
    $bin/arm-linux-androideabi-gcc -c ./main.c -o ./obj/main.o 
    $bin/arm-linux-androideabi-gcc ./obj/main.o -o ./obj/main.exe 

the output of gcc gives a message from ld (arm-linux-androideabi-ld) that it terminated as 7 (second comma-delimited is ARM) signal.

This simple program won't even compile on Linux, please help!

解决方案

I have installed static tool chain in ubuntu 12.4

sudo apt-get install gcc-arm-linux-gnueabi  // install this toolchain 

arm-linux-gnueabi-gcc -static -o main.exe main.c  // this way compile ur binary

copy through adb in android machine and run

./main.exe

this works in my android mobile.

Edit:

for 10.04

   sudo add-apt-repository ppa:linaro-maintainers/toolchain
    sudo apt-get update
    sudo apt-get install gcc-arm-linux-gnueabi

Edit2: Its static compilation here it doesnt use bionic code and it include libraries by copying them into the ELF.

If you want to dynamic compilation or want to depend on bionic code then use

$NDK/docs/STANDALONE-TOOLCHAIN.html https://android.googlesource.com/platform/ndk/+/master/docs/STANDALONE-TOOLCHAIN.html

这篇关于Android的GCC SYSROOT和连接器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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