无法执行二进制文件:Exec 格式错误 64 位
cannot execute binary file: Exec format error 64bits
我在 Windows Linux 子系统下,它在其他计算机上运行良好。
我有一个 64 位文件:./ensembles.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
uname -m
: x86_64
我尝试使用 gcc
编译器和 clang
编译器,两者都很松散。
即使这个 C 代码也不起作用:
#include <stdio.h>
#include <stdlib.h>
#include "sac.h"
#include "type_ensemble.h"
#include "operations_ens.h"
int main(int argc, char ** argv) {
}
错误:-bash: ./ensembles.o: cannot execute binary file: Exec format error
我的生成文件:
ensembles.o : ensembles.c sac.h type_ensemble.h operations_ens.h
gcc -c ensembles.c
operation_ens.o : operations_ens.c operations_ens.h
gcc -c operations_ens.c
sac.o : sac.c sac.h
gcc -c sac.c
main: ensembles.o operation_ens.o sac.o
gcc -o main ensembles.o operation_ens.o sac.o
A file of type ELF 64-bit LSB relocatable 是 ELF type ET_REL 的文件,不能直接执行。它通常称为目标文件或 .o
文件,它是 link 编辑器的输入文件。
您需要 link 它(使用 gcc
或 ld
命令)来生成可执行文件。如果您正在调用 gcc
,则不得传递 -r
或 -c
等选项,否则 GCC 将不会生成可执行文件。
在你引用的makefile中,只有第一个目标会被make执行,因为它是默认目标。尝试将 main
的规则移动到文件的开头,或添加规则
all: main
开头。您还可以调用 make main
来请求显式构建 main
文件。
我在 Windows Linux 子系统下,它在其他计算机上运行良好。
我有一个 64 位文件:./ensembles.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
uname -m
: x86_64
我尝试使用 gcc
编译器和 clang
编译器,两者都很松散。
即使这个 C 代码也不起作用:
#include <stdio.h>
#include <stdlib.h>
#include "sac.h"
#include "type_ensemble.h"
#include "operations_ens.h"
int main(int argc, char ** argv) {
}
错误:-bash: ./ensembles.o: cannot execute binary file: Exec format error
我的生成文件:
ensembles.o : ensembles.c sac.h type_ensemble.h operations_ens.h
gcc -c ensembles.c
operation_ens.o : operations_ens.c operations_ens.h
gcc -c operations_ens.c
sac.o : sac.c sac.h
gcc -c sac.c
main: ensembles.o operation_ens.o sac.o
gcc -o main ensembles.o operation_ens.o sac.o
A file of type ELF 64-bit LSB relocatable 是 ELF type ET_REL 的文件,不能直接执行。它通常称为目标文件或 .o
文件,它是 link 编辑器的输入文件。
您需要 link 它(使用 gcc
或 ld
命令)来生成可执行文件。如果您正在调用 gcc
,则不得传递 -r
或 -c
等选项,否则 GCC 将不会生成可执行文件。
在你引用的makefile中,只有第一个目标会被make执行,因为它是默认目标。尝试将 main
的规则移动到文件的开头,或添加规则
all: main
开头。您还可以调用 make main
来请求显式构建 main
文件。