交叉编译的HelloWorld为ARM

交叉编译的HelloWorld为ARM

本文介绍了交叉编译的HelloWorld为ARM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个ARM的CORTEX-A9一个简单的交叉编译(CC):
为了简单起见,多数民众赞成在C- code:

 的#include<&stdio.h中GT;
诠释的main()
{
   的printf(的Hello World \\ n!);
   返回0;
}

在手臂上的本地编译工作正常,并开始与的gcc -o helloworld.c的HelloWorld ,而交叉编译开始与设防赛灵思Linux的gnueabi-GCC helloworld.c -o helloworld_cc

GCC版本:

NATIV: gcc版本4.6.3(Ubuntu的/ Linaro的4.6.3-1ubuntu5)目标:手臂-Linux的gnueabihf

CC: gcc版本4.6.3(的Sourcery codeBench精简版2012.03-79)目标:手臂,赛灵思Linux的gnueabi

ABI从readelf:

readelf-NATIV:操作系统:Linux,ABI:2.6.31
readelf-CC:操作系统:Linux,ABI:2.6.16

链接库 - 编译十字架是静态链接的所以应该不会错过任何一个库:

 根@本地:/ TEMP#LDD​​的HelloWorld
        libc.so.6的= GT; /lib/arm-linux-gnueabihf/libc.so.6(0xb6ed8000)
        /lib/ld-linux-armhf.so.3(0xb6fce000)
根@本地:/ TEMP#LDD​​ helloworld_cc
        不是一个动态可执行文件

问题:本地PROGRAMM运行正常,消委会始终以结束:

 根@本地:/ tmp目录#./helloworld_cc
-bash:./helloworld_cc:没有这样的文件或目录

任何提示,希望我已经包括了足够的信息。

修改

链接为静态的伎俩,但现在文件的大小是巨大的(678KB(CC静态)与4kB的(本机)?为什么缺少的库,即使它说,它不是动态链接?类似的问题:Cross编译使用静态C的hello world为Android臂Linux的gnueabi-GCC

  ARM-赛灵思Linux的gnueabi-GCC helloworld.c -o helloworld_cc -static


解决方案

疗法是LIB 文件夹Linaro的Ubuntu的在一个缺失的环节。这表明了 readelf -a

  [请求程序间preTER:/lib/ld-linux.so.3]

把链接的lib / LD-linux.so.3 的lib / ARM-Linux的gnueabihf / ld-2.15.so

和它的作品。

感谢您的帮助谢尔盖

I'm trying a simple cross compile (cc) for an ARM-CORTEX-A9:To keep things simple thats the c-code:

#include <stdio.h>
int main()
{
   printf("Hello World!\n");
   return 0;
}

The native compilation on the arm works fine and is started with gcc helloworld.c -o helloworld whereas the cross compile is started with arm-xilinx-linux-gnueabi-gcc helloworld.c -o helloworld_cc

GCC Version:

nativ: gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) Target: arm-linux-gnueabihf

CC: gcc version 4.6.3 (Sourcery CodeBench Lite 2012.03-79) Target: arm-xilinx-linux-gnueabi

ABI from readelf:

readelf-nativ: OS: Linux, ABI: 2.6.31readelf-cc: OS: Linux, ABI: 2.6.16

Linked libs - the cross compiled is static linked so it shouldn't miss any libs:

root@localhost:/temp# ldd helloworld
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6ed8000)
        /lib/ld-linux-armhf.so.3 (0xb6fce000)
root@localhost:/temp# ldd helloworld_cc
        not a dynamic executable

The Problem: the native Programm runs fine, the cc always ends up with:

root@localhost:/tmp# ./helloworld_cc
-bash: ./helloworld_cc: No such file or directory

Any hints, hopefully I have included enough information.

edit

Linking it static does the trick, but now the size of the file is huge (678kB (CC-static) vs. 4kB(native)? Why is it missing libs even if it says it is not dynamically linked? Similar question: Cross compiling static C hello world for Android using arm-linux-gnueabi-gcc

arm-xilinx-linux-gnueabi-gcc helloworld.c -o helloworld_cc -static
解决方案

Ther was a missing link in the lib folder Linaro Ubuntu. It showed up with readelf -a

[Requesting program interpreter: /lib/ld-linux.so.3]

Putting the link lib/ld-linux.so.3 to lib/arm-linux-gnueabihf/ld-2.15.so

and it works.

Thanks for the help Sergey

这篇关于交叉编译的HelloWorld为ARM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 08:41