当前位置:网站首页>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 .
边栏推荐
- [luogu] p1083 [noip2012 improvement group] classroom borrowing (difference)
- Thread local storage understanding
- SYSTEMd summary
- Cmake simple usage
- //1.13 auto increment and auto decrement operators (+ +, --)
- 11. function template, class template, implementation vector sequence container, and space adapter
- Install MySQL (5.7+8.0) through docker and configure master-slave replication (gtid+ enhanced semi synchronization)
- Vscade personalization: let a cute girl knock the code with you
- [template] KMP
- On AI and its future trend | community essay solicitation
猜你喜欢

An interesting example of relaxed memory models

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

Binary String

Constexpr keyword

office2016+visio2016

SQL programming task03 job - more complex query

MySQL -- how to access the database of a computer in the same LAN (prenatal education level teaching)
![[Title Fine brushing] 2023 Hesai FPGA](/img/e8/d9d8c549a4fee529b69ebfc9a9d6ef.png)
[Title Fine brushing] 2023 Hesai FPGA

On AI and its future trend | community essay solicitation
![[hdu] P6964 I love counting](/img/ff/f8e79d28758c9bd3019816c8f46723.png)
[hdu] P6964 I love counting
随机推荐
Extend your kubernetes API using the aggregation API
C# SerializableDictionary序列化/反序列化
Debian10 configuring rsyslog+loganalyzer log server
Download and compile ROS source code
Detailed explanation of clip attribute parameters
Day260: the number III that appears only once
C serializabledictionary serialization / deserialization
Score and loop statements (including goto statements) -part3
Primary pointer part
Big guys, 2.2.1 the CDC monitoring SQLSEVER can only get the full amount of data. Why can't we get the incremental data in the later period
OOP multiple storage (class template)
Function part
Pat class A - 1012 the best rank (PIT)
9. class and object practice and initialization list
Day367: valid complete square
1. introduction to MySQL database connection pool function technology points
Use of higher order functions
"First knowledge of C language" (Part 3)
//1.7 use of escape characters
Express framework installation and start service