我正在为 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.31
readelf-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.3
至 lib/arm-linux-gnueabihf/ld-2.15.so
它有效。
感谢您的帮助谢尔盖
关于gcc - ARM 交叉编译 helloworld,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16935168/