gcc - ARM 交叉编译 helloworld

标签 gcc arm cross-compiling

我正在为 ARM-CORTEX-A9 尝试一个简单的交叉编译 (cc):
为了简单起见,这就是 c 代码:

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

arm 上的 native 编译工作正常,以 gcc helloworld.c -o helloworld 开头,而交叉编译以 arm-xilinx-linux-gnueabi-gcc helloworld.c -o helloworld_cc 开头

GCC 版本:

原生:gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) Target: arm-linux-gnueabihf
抄送:gcc version 4.6.3 (Sourcery CodeBench Lite 2012.03-79) Target: arm-xilinx-linux-gnueabi
来自 readelf 的 ABI:

readelf 原生:OS: Linux, ABI: 2.6.31readelf-cc:OS: Linux, ABI: 2.6.16
链接库 - 交叉编译是静态链接的,所以它不应该错过任何库:
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

问题: native 程序运行良好,cc 总是以:
root@localhost:/tmp# ./helloworld_cc
-bash: ./helloworld_cc: No such file or directory

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

编辑

静态链接它可以解决问题,但现在文件的大小很大(678kB(CC-static)与 4kB( native )?为什么即使它说它不是动态链接它也缺少库?类似的问题:Cross compiling static C hello world for Android using arm-linux-gnueabi-gcc
arm-xilinx-linux-gnueabi-gcc helloworld.c -o helloworld_cc -static

最佳答案

lib 中有一个缺失的链接文件夹 Linaro Ubuntu。它出现了 readelf -a

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

放链接lib/ld-linux.so.3lib/arm-linux-gnueabihf/ld-2.15.so
它有效。

感谢您的帮助谢尔盖

关于gcc - ARM 交叉编译 helloworld,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16935168/

相关文章:

c - C语言嵌入ARM汇编

android-ndk - 无法将库从 Windows 交叉编译到 Android

c++ - 将右值指定为返回值时出现段错误

c++ - strcpy_s 不适用于 gcc

c - 为什么 malloc(sizeof(pointer)) 有效?

protocol-buffers - 运行 protoc 时是否可以指定输出版本?

fortran - 如何在 fortran 中更改目标机器配置?

C 结构 - 错误 : unknown type name between two files

xcode - 可以对 Xcode 中的 arm 架构设置进行一些说明

linux - 尝试为 ARM 构建 GDB 时出错