首页 > 为什么c语言源文件编译后没有创建对象文件.obj,而是直接生成可执行文件.exe?

为什么c语言源文件编译后没有创建对象文件.obj,而是直接生成可执行文件.exe?

为什么c语言源文件编译后没有创建对象文件.obj,而是直接生成可执行文件.exe?
我在教材里看到,c语言源文件编译后会产生扩展名为.obj的对象文件,可是我在编译后只有生成一个.exe的可执行文件,这是为什么?


gcc -o a.obj

-o file
Place output in file file. This applies to whatever sort of output is being produced, whether is be an executable file, an object file, an assemble file or preprocessed C code.
If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s. a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.
-man page


gcc -c main.c
使用-c参数告诉编译器的driver只执行编译

gcc main.c
编译器的driver会执行编译,在一个临时目录中生成.o文件,再执行链接,生成可执行文件。

windows下使用MS 编译器同理,不过不知到具体的参数是什么。


加 -o 参数试试


gcc -g -O -c main.c


我认为是IDE帮你直接编程了exe
我记得 编译器 一般都是先编 out文件

【热门文章】
【热门文章】