Makefile-o,为什么需要.o 当我们想要一起编译一个多文件时。 为什么我们需要在makefile中将.c文件转换为.o,而不仅仅是gcc file1.c file2.c-o新文件

Makefile-o,为什么需要.o 当我们想要一起编译一个多文件时。 为什么我们需要在makefile中将.c文件转换为.o,而不仅仅是gcc file1.c file2.c-o新文件,c,gcc,makefile,compiler-errors,C,Gcc,Makefile,Compiler Errors,比如说 \\ in make file file: file1.c file2.c gcc file1.c file2.c -o combination \\ we can just call make in the terminal \\ i have watch video on youtube, why people using file1.o file2.o. why we need to convert .c file to .o instead of just gcc

比如说

\\ in make file
file: file1.c file2.c 
     gcc file1.c file2.c -o combination

\\ we can just call make in the terminal
\\ i have watch video on youtube, why people using file1.o file2.o. why we need to convert .c file to .o instead of just gcc the file and ./ execute it?

你不需要。继续这样做吧;对于非常简单的情况,它可以很好地工作

当(a)您需要记住或告诉其他人一些编译器标志,和/或(b)您开始获得足够的文件,以便在任何更改花费太长时间时重新编译所有文件,因此您只想重新编译更改的文件时,Makefiles非常有用。

可能相关: