当前位置:网站首页>Makefile demo
Makefile demo
2022-07-03 03:39:00 【___ Bozi mi pro】
make Tools are a basis makefile The contents of the document , Target ( Executable file ) Perform dependency detection ( What intermediate files are required before generating the executable ) And perform the relevant actions ( Compile etc. ) Tools for . And this makefile The file is similar to a script , The content includes make Processing actions to be performed and dependencies .
makefile The main content to be carried out is to clarify the goal 、 Clarify what the goal depends on 、 Specify that the corresponding processing actions should be performed when the dependency conditions are met . For example, we will finally realize a This goal , But you have to rely on b, and b Depend on c The existence of , Can be described as :
a:b
cmdbtoa
b:c
cmdctob
“:” On behalf of dependence , In addition, you should use before each processing action tab The key to separate . The four lines above mean :a Depend on b, And deal with cmdbtoa;b Depend on c, And deal with cmdctob.
gcc Yes C/C++ Compilation process , It is divided into four parts , Preprocessing , compile , assembly , link .
makefile1:
C = gcc
G = g++
CFLAGS = -Wall -O -g
TARGET = ./test
# Means to put all .c、.cpp File compiled into .o file .
# $ @ Expand to the destination file name of the current rule
# $ < Expand to the first dependency file in the dependency list
# $^ Expand to the entire list of dependencies ( Get rid of all duplicate file names ).
%.o:%.c
$(C) $(CFLAGS) -c $< -o [email protected]
%.o:%.cpp
$(G) $(CFLAGS) -c $< -o [email protected]
# Means to generate an all with .c、.cpp List of files at the end , Then store the variable SOURCES in .
SOURCES = $(wildcard *.c *.cpp)
# hold SOURCES All files in the file list .cpp become .o、.c become .o, Then form a new list , Deposit in OBJS Variable .
OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES)))
$(TARGET):$(OBJS)
$(G) $(OBJS) -o $(TARGET)
#chmod a+x $(TARGET) Express the firstTest Force into executable
chmod a+x $(TARGET)
clean:
rm -rf *.o test
makefile2:
#“:” On behalf of dependence , In addition, you should use before each processing action tab The key to separate .
OBJS = test1.o test2.o
G = gcc
# CFLAGS = -Wall -O -g Configure compiler settings , And assign it to CFLAGS Variable
# -Wall: Output all warning messages
# -O: Optimize at compile time
# -g: Represents compilation debug edition
CFLAGS = -Wall -O -g
test:$(OBJS)
$(G) $(OBJS) -o test
test1.o:test1.c test2.h
$(G) $(CFLAGS) -c test1.c
test2.o:test2.c test2.h
$(G) $(CFLAGS) -c test2.c
clean:
rm -rf *.o test
边栏推荐
- [combinatorics] number of solutions of indefinite equations (number of combinations of multiple sets R | number of non negative integer solutions of indefinite equations | number of integer solutions
- ffmpeg之 一张/多张图片合成视频
- Convert binary stream to byte array
- IPv6 transition technology-6to4 manual tunnel configuration experiment -- Kuige of Shangwen network
- 使用InputFilter限制EditText时踩坑及解决方案
- Hutool动态添加定时任务
- Mongodb master profile
- MongoDB簡介
- redis在服务器linux下的启动的相关命令(安装和配置)
- 如何迈向IPv6之IPv6过渡技术-尚文网络奎哥
猜你喜欢
TCP/IP模型中的重磅嘉宾TCP--尚文网络奎哥
PHP generates PDF tcpdf
LVGL使用心得
[embedded module] OLED display module
Ffmpeg recording screen and screenshot
FileZilla client download and installation
Don't use the new Dede collection without the updated Dede plug-in
Lvgl usage experience
Summary of electromagnetic spectrum
Vs 2019 configuration tensorrt
随机推荐
Applet get user avatar and nickname
使用InputFilter限制EditText时踩坑及解决方案
简易版 微信小程序开发之for指令、上传图片及展示效果优化
[set theory] partial order relation (partial order relation definition | partial order set definition | greater than or equal to relation | less than or equal to relation | integer division relation |
用Three.js做一個簡單的3D場景
Basic operations of mongodb [add, delete, modify, query]
Latest version of NPM: the "NPM" item cannot be recognized as the name of a cmdlet, function, script file, or runnable program. Please check
Web会话管理安全问题
Change and access of median value of listening object
Makefile demo
Téléchargement et installation du client Filezilla
User value is the last word in the competition of mobile phone market
动态规划:最长回文子串和子序列
Using jasmine to monitor constructors - spying on a constructor using Jasmine
Limit of one question per day
Hi3536C V100R001C02SPC040 交叉编译器安装
C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions
Nce detail of softmax approximation
leetcode:动态规划模板
Compare float with 0