In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use Makefile in Linux". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use Makefile in Linux".
In a nutshell, the function of Makefile is "automatic compilation". When we have written the Makefile of the entire project, we only need a simple make command to achieve automatic compilation.
Naming of 1.makefile (two kinds)
Makefile
Makefile
2. Rules of makefile
Three elements of a rule: goal, dependency, and command
3. The writing of multi-file makefile (a source file only recompiles the changed file)
Makefile can have multiple rules, and when the command of the first rule is executed without a corresponding dependency, look for it in the following rule. The goal of the top rule is that the ultimate goal must be written at the top, that is, the final file to be generated.
Update principle of multi-file Makefile (based on time)
4. Variables in makefile
Custom variable
Obj=main.o add.o sub.o
Use $(obj) directly when referencing
Automatic variable ()
$@: target in the rule
$^: all dependencies in the rule
Automatic pattern matching%
In the subrules:
Variables maintained by makefile (usually uppercase and can be modified by yourself)
CC:cc (i.e. gcc)
APPFLAGS: options used for preprocessing
CFLAGS: options to use when compiling
LDFLAGS: options used by linked libraries
5. Functions in makefile (all have return values)
Wildcard finds all .c files in the current directory and returns the value to src
Src=$ (wildcard. / * .c)
Patsubst replaces all .c files with .o files
Obj=$ (patsubst. /% .c,. /% .o, $(src))
6. Make clean
Add the goal of clean at the end of makefile. In order to recompile all files, you have to delete the original generated files.
7. The final simple makefile
Thank you for your reading, the above is the content of "how to use Makefile in Linux". After the study of this article, I believe you have a deeper understanding of how to use Makefile in Linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.