bash: ./main.o: cannot execute binary file: Exec format error解决方法

在linux中使用make编译文件后执行./main.o,出现了bash: ./main.o: cannot execute binary file: Exec format error的错误。

解决方法:

将malefile中的

TARGET := main.o

改为:

TARGET := test.o

然后在make后,执行./test.o。完全ok.

原因分析:因为在makefile中已经有了文件main.c生成对应的main.o的目标文件。如下:

C_OBJS += $(MAIN_PATH)main.o

然而,最终的目标文件也和main.o文件名相同。所以出现了这个问题。

猜你喜欢

转载自blog.csdn.net/u010299133/article/details/79420951
今日推荐