eac*_*tor 13 gcc arm cross-compiling
我正在为ARM-CORTEX-A9尝试一个简单的交叉编译(cc):为了简单起见,这就是c代码:
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
arm上的本机编译工作正常,并gcc helloworld.c -o helloworld以交叉编译开始时开始arm-xilinx-linux-gnueabi-gcc helloworld.c -o helloworld_cc
GCC版本:
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
来自readelf的ABI:
readelf-nativ: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
Run Code Online (Sandbox Code Playgroud)
问题:本机程序运行正常,cc总是以:
root@localhost:/tmp# ./helloworld_cc
-bash: ./helloworld_cc: No such file or directory
Run Code Online (Sandbox Code Playgroud)
任何提示,希望,我已经包含了足够的信息.
编辑
将它链接到静态就可以了,但现在文件的大小很大(678kB(CC静态)与4kB(本机)?为什么它缺少libs,即使它说它没有动态链接?类似的问题:交叉编译使用arm-linux-gnueabi-gcc的Android静态C hello world
arm-xilinx-linux-gnueabi-gcc helloworld.c -o helloworld_cc -static
Run Code Online (Sandbox Code Playgroud)
Ther是libLinaro Ubuntu文件夹中缺少的链接.它出现了readelf -a
[Requesting program interpreter: /lib/ld-linux.so.3]
Run Code Online (Sandbox Code Playgroud)
把链接lib/ld-linux.so.3放到lib/arm-linux-gnueabihf/ld-2.15.so
它的工作原理.
谢谢谢谢谢谢
| 归档时间: |
|
| 查看次数: |
26938 次 |
| 最近记录: |