【发布时间】:2017-04-14 13:34:10
【问题描述】:
我编写了简单的 Hello world 程序并使用gcc-arm-linux-gnueabi 编译器编译它。它编译得很好,但是当我尝试在 ARM 机器上执行它时,它会抱怨“没有这样的文件或目录”。我认为gcc-arm-linux-gnueabi 仅适用于嵌入式 Linux,因为 e(mbedded)abi。和 ARM Linux ABI 有区别吗?
请帮我解决这个问题
代码在这里
#include "stdio.h"
int main(void) {
printf("Hello world !\n");
return 0;
}
编译为
arm-linux-gnueabi-gcc -Wall -o crosscomp hello.c
当我在目标 ARM 机器上执行这个 crosscomp 时,错误是 crosscomp no such file or dir
编辑 当我使用 arm-linux-gnueabi-gcc 时,入口点与目标机器入口点(readelf -l crosscom)不匹配,但是当我使用 aarch64-linux-gnu 编译时-gcc 入口点与目标机器匹配。但是现在错误变成了./crosscomp 上的权限被拒绝。我试过 sudo,它说 crosscomp: no such command。
注意我在 askubuntu https://askubuntu.com/questions/904685/cross-compilation-for-arm-error-no-such-file-or-directory 上发布了同样的问题,但没有得到回应。
readelf的输出如下
ELF 标头:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: AArch64
Version: 0x1
Entry point address: 0x400470
Start of program headers: 64 (bytes into file)
Start of section headers: 4488 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 8
Size of section headers: 64 (bytes)
Number of section headers: 29
Section header string table index: 26
【问题讨论】:
-
ls -l crosscomp的输出是什么? -
好的,简而言之,这个错误是因为工具链不适用于目标ARM处理器,您需要使用与编译目标板rootfs完全相同的工具链。
-
谢谢高拉夫。发现该工具链的任何建议
-
你可以参考这个link。从该目标 rootfs 上的任何二进制文件,可能是busybox。如果 cmets 没有被剥离。
-
参考供应商网站。它应该有工具链或 BSP 下载链接。你能告诉我,你从哪里得到这个板的 BSP 或者你是如何为它编译文件系统的?
标签: c linux gcc arm cross-compiling