当前位置:网站首页>Detailed explanation of makefile usage
Detailed explanation of makefile usage
2022-06-23 01:47:00 【Chongyou research Sen】
Previously introduced gcc 了 , This article is mainly in gcc Later, in order to facilitate the compilation of the file !
This chapter is divided into two parts : Makefile The basic way of writing Makefile Variable substitution writing
No more nonsense , Let's go straight to work !
Makefile The basic way of writing :
The following documents are included in the project :( For program content, please refer to atomic brother Makefile chapter !)

By the previous gcc You know , We can compile directly , But trouble , So we're right now Makefike Documents are written ( The name should be Makefile!), The contents are as follows :
ljs: main.o input.o calcu.o
gcc -o ljs main.o input.o calcu.o
main.o: main.c
gcc -c main.c
input.o: input.c
gcc -c input.c
calcu.o: calcu.c
gcc -c calcu.c
clean:
rm *.o
rm ljsThe code analysis : Do the following make

Executable file ljs Depend on these three .o file , And then for these three .o File for compilation
main.o Depend on main.c. Then on main.c Compile
The code analysis : Do the following make clean

Through the above Makefile Set up , So after we change one of the programs , The system will only compile the changed , What has not been modified will not change , give the result as follows :

summary : This kind of writing is easy to understand , But it's more troublesome , The variable substitution described below will be simpler !
Makefile Variable substitution How to write it :

Program analysis : Set string main.o input.o calcu.o And assign it to objects
$ Is the prefix of a variable , That is to say ljs Dependent on variables objects
%.c Express all .c file
Like everything else
On the file make and make clean You can get the same effect .
边栏推荐
- Autumn move script C
- Vector 6 (inheritance)
- Byte order: big endian vs little endian
- Express framework installation and start service
- 165. cat climbing
- SQL programming task04 job - set operation
- Nuxt - auto generate dynamic route bug
- Using WordPress to create a MySQL based education website (learning notes 2) (technical notes 1) xampp error1045 solution
- Binary String
- Data skew analysis of redis slice cluster
猜你喜欢

4. functions and inline functions with default values for formal parameters

Lexical Sign Sequence

Branch and loop statements (including goto statements) -part1
![[Title Fine brushing] 2023 Hesai FPGA](/img/e8/d9d8c549a4fee529b69ebfc9a9d6ef.png)
[Title Fine brushing] 2023 Hesai FPGA

Freshman C language summary post (hold change) Part 2 formatted monthly calendar

3D printing microstructure

SFOD:无源域适配升级优化,让检测模型更容易适应新数据

There are animation characters interacting with each other when the mouse slides in the web page

8. destruct, construct, deep copy, shallow copy, assignment operator overload

Network module packaging
随机推荐
Cmake simple usage
SYSTEMd summary
//1.13 auto increment and auto decrement operators (+ +, --)
//1.9 char character variable operation
The road of architects starts from "storage selection"
[ZOJ] P3228 Searching the String
1. introduction to MySQL database connection pool function technology points
[hdu] P6964 I love counting
There is no corresponding change on the page after the code runs at the Chrome browser break point
Autumn move script a
[luogu] p1083 [noip2012 improvement group] borrow classroom (line segment tree)
Cmake passing related macros to source code
On function overloading from several examples
"Initial C language" (Part 2)
MySQL -- how to access the database of a computer in the same LAN (prenatal education level teaching)
[luogu] p1083 [noip2012 improvement group] classroom borrowing (difference)
Epoll introduction and principle explanation
Is it safe for Hongyuan futures to open an account? Can Hongyuan futures company reduce the handling fee?
5. explain function overloading
Bc113 small leloding alarm clock