首页 > 解决方案 > gcc 命令中的 .o 文件是什么?

问题描述

gcc -o file1 file1.o file2.o file3.o

我对 C 没有太多经验,并且Makefile在我们的系统中找到了上述内容。

在这种情况下,什么是.o文件,什么是 file1.o?有关系file1吗?

标签: cmakefile

解决方案


-o file

Place output in file file. This applies regardless to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code.

Since only one output file can be specified, it does not make sense to use '-o' when compiling more than one input file, unless you are producing an executable file as output.

Here executable file produced is file1

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, and all preprocessed C source on standard output.

.o files are compiled object file of your c code file.

Qouted here -> GCC Command-Line Options


推荐阅读