不了解“ gcc -c file.c”和“ gcc -o file.c”命令之间的区别

问题描述 投票:0回答:1

命令:

`gcc -c -Wall hello.c`

这里是错误:调用./ hello.o时>
bash: ./hello.o: cannot execute binary file: Exec format error

需要帮助..

命令:`gcc -c -Wall hello.c`这是错误:调用./hello.o时bash:./hello.o:无法执行二进制文件:Exec格式错误需要帮助。.

linux gcc compilation execution
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.