当前位置:网站首页>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 testmakefile2:
#“:” 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边栏推荐
- Ffmpeg one / more pictures synthetic video
- LVGL使用心得
- QQ小程序开发之 一些前期准备:预约开发账号、下载安装开发者工具、创建qq小程序
- 可分离债券与可转债
- MongoDB简介
- Nanning water leakage detection: warmly congratulate Guangxi Zhongshui on winning the first famous brand in Guangxi
- node 开启服务器
- Recursive use and multi-dimensional array object to one-dimensional array object
- C programming learning notes [edited by Mr. Tan Haoqiang] (Chapter III sequence programming) 03 operators and expressions
- Numpy warning visibledeprecationwarning: creating an ndarray from ragged needed sequences
猜你喜欢

Summary of determinant knowledge points in Chapter 1 of Linear Algebra (Jeff's self perception)
![[embedded module] OLED display module](/img/c4/474f5ee580d132654fbd1a4cd53bab.jpg)
[embedded module] OLED display module

递归:一维链表和数组

TCP/IP模型中的重磅嘉宾TCP--尚文网络奎哥

umi 路由拦截(简单粗暴)

Web会话管理安全问题

Ffmpeg one / more pictures synthetic video
![[pyg] understand the messagepassing process, GCN demo details](/img/8b/8490aac98fd2753e661f74e284f43d.png)
[pyg] understand the messagepassing process, GCN demo details

Lvgl usage experience

ffmpeg之 一张/多张图片合成视频
随机推荐
Introduction to mongodb
How to move towards IPv6: IPv6 Transition Technology - Shangwen network quigo
User value is the last word in the competition of mobile phone market
Advanced redis applications [password protection, data persistence, master-slave synchronization, sentinel mode, transactions] [not completed yet (semi-finished products)]
Don't use the new Dede collection without the updated Dede plug-in
ffmpeg录制屏幕和截屏
Simple wechat applet development page Jump, data binding, obtaining user information, obtaining user location information
MongoDB簡介
Recursion: depth first search
Introduction à mongodb
动态规划:最长公共子串和最长公共子序列
New programmers use the isXXX form to define Boolean types in the morning, and are discouraged in the afternoon?
Application of derivative in daily question
IPv6 transition technology-6to4 manual tunnel configuration experiment -- Kuige of Shangwen network
Makefile demo
MongoDB简介
On the adjacency matrix and adjacency table of graph storage
node 开启服务器
递归:一维链表和数组
小程序获取用户头像和昵称