如何修复 raspberry pi 4 上的 exec 格式错误
How can I fix exec format error on raspberry pi 4
我正在尝试使用 ubuntu 服务器 20.04.1 LTS 在 raspberry pi 4 上编译代码。我正在使用 gcc 来编译它,每次我尝试 运行 成功编译后的文件时,它都会说
-bash: ./out: cannot execute binary file: Exec format error
当我在 out 上执行文件命令时,我知道 ARM cpu 是 64 位
out: ELF 64-bit LSB relocatable, ARM aarch64, version 1(SYSV), not stripped
这是我正在尝试的来源 运行
#include <stdio.h>
#include <stdlib.h>
int main(){
printf("Hello World!");
return 0;
}
这是我运行ning
的gcc命令
gcc -march=native -ctest.c -oout
这是一个“LSB 可重定位”文件,由于尚未 link 编辑,因此不可执行,因为您的命令命令 gcc -march=native -ctest.c -oout
中的 -c
代表“编译和仅 assemble,不 link":
$ gcc --help
<...>
-c Compile and assemble, but do not link.
<...>
您应该将所有内容编译成可执行文件:
gcc -march=native test.c -o out
我正在尝试使用 ubuntu 服务器 20.04.1 LTS 在 raspberry pi 4 上编译代码。我正在使用 gcc 来编译它,每次我尝试 运行 成功编译后的文件时,它都会说
-bash: ./out: cannot execute binary file: Exec format error
当我在 out 上执行文件命令时,我知道 ARM cpu 是 64 位
out: ELF 64-bit LSB relocatable, ARM aarch64, version 1(SYSV), not stripped
这是我正在尝试的来源 运行
#include <stdio.h>
#include <stdlib.h>
int main(){
printf("Hello World!");
return 0;
}
这是我运行ning
的gcc命令gcc -march=native -ctest.c -oout
这是一个“LSB 可重定位”文件,由于尚未 link 编辑,因此不可执行,因为您的命令命令 gcc -march=native -ctest.c -oout
中的 -c
代表“编译和仅 assemble,不 link":
$ gcc --help
<...>
-c Compile and assemble, but do not link.
<...>
您应该将所有内容编译成可执行文件:
gcc -march=native test.c -o out