C_MAKEFILE
GCC
gcc hello.c -o hello
Course resources 12. Compilation and Makefiles
code.c
1 |
|
Preprocessing
Removes preprocessor directives (commands that start with #)
Producescode.i Don’tusedirectly
1 |
|
output: code.i
Compiling
Convertssourcecodetomachinelanguagewithunresolveddirectives
Producesthecode.obinary
1 |
|
output: code.o
Linking
Createsmachinelanguageexectutable
Producesthecodebinarybylinkingwiththemathlibrary(‐lm)
1 |
|
output: code
-c
(Compile only)
i think it equals gcc -E and gcc - o
Purpose: Tells GCC to compile the source code into an object file (
.o
or.obj
), but not to link it.Usage: This is used when you want to compile source files without producing an executable, typically to be linked later in a separate step.
Example
:
1
bash
Copy
gcc -c myfile.c
1 |
|
myfile.o
1 |
|
Makefile
https://www.gnu.org/software/make/manual/make.html
Make/make.md · 无限十三年/CPP - Gitee.com
https://www.bilibili.com/video/BV1Bv4y1J7QT
hello.cpp
1 |
|
MakeFile
1 |
|
make