首页 > 解决方案 > don't understand the difference between "gcc -c file.c" and "gcc -o file.c" command

问题描述

Command :

`gcc -c -Wall hello.c`

Here is the error : while calling ./hello.o

bash: ./hello.o: cannot execute binary file: Exec format error

need help please ..

标签: linuxgcccompilationexecution

解决方案


.o 是目标文件,而不是可执行文件。这是一个中间步骤。-c 选项只是说要迈出这一步。您仍然必须将该目标文件链接到可执行文件中。


推荐阅读