Intro to Makefile
来源:互联网 发布:做淘宝刷客犯法吗 编辑:程序博客网 时间:2024/05/29 07:24
Abstract
This blog will show you how to write a “makefile” file.
1. Concept
A makefile is a file containing a set of directives, directing a complier to link a program in a certain order.
2. An Example
file1.h
#ifndef file1_h#define file1_hvoid tool1(char *);void tool1(const char *);#endif
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 1
- 2
- 3
- 4
- 5
- 6
- 7
file1.cpp
#include <stdio.h>#include "file1.h"void tool1(char *str){ printf("This is file1 print: %s\n",str);}void tool1(const char *str){ printf("This is file1 print: %s\n",str);}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
file2.h
#ifndef file2_h#define file2_hvoid tool2(char *);void tool2(const char *);#endif
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 1
- 2
- 3
- 4
- 5
- 6
- 7
file2.cpp
#include <stdio.h>#include "file2.h"void tool2(char *str){ printf("This is file2 print: %s\n",str);}void tool2(const char *str){ printf("This is file2 print: %s\n",str);}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
main.cpp
#include <stdio.h>#include <stdlib.h>#include "file1.h"#include "file2.h"int main(){ char str1[] = "hello"; tool1(str1); const char str1_c[] = "hello"; tool1(str1_c); char str2[] = "hello"; tool2(str2); const char str2_c[] = "hello"; tool2(str2_c);}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
makefile
CC := g++CFLAGS := -gTARGET := targetSRCS := $(wildcard *.cpp)OBJS := $(patsubst %cpp,%o,$(SRCS))all:$(TARGET) clean%.o:%.cpp $(CC) $(CFLAGS) -c $<$(TARGET):$(OBJS) $(CC) $(CFLAGS) -o $@ $^clean: rm -rf *.o
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
3. Reference
https://github.com/Canhui/C-Plus-Standard-By-Practice/tree/master/Project_1_Makefile
http://blog.csdn.net/wallwind/article/details/6791505
http://wenku.baidu.com/link?url=P2odKaCA4zRTieikBQoaSD77YBOQTbnG0D3VHxNdTJDTsitCNsKdrZIgxfRfW2vrdpPFhfMuHfWJHfwDPWFrTT-KnXD7GBJBTxYvSxiRDh3
0 0
- Intro to Makefile
- Intro to Makefile
- Intro to Expect
- Intro to Node.js
- Intro to Apache Maven
- intro to JNDI
- Intro to Bilinear Maps
- The quick intro to libipq
- intro to chrome addons hacking
- Brief Intro to Foundation Functions
- Brief Intro to Expression Literals
- intro to Apache Log4j 2
- A cartoon intro to Redux
- Introduction to R Intro to basics answer
- Intro
- intro
- Intro
- An Intro to Constructors in C#
- [高性能MySQL]-特定类型查询的优化
- C++的重载、覆盖、隐藏、继承
- java并发感觉很实用的博客专栏
- 【例题】Oracle中怎么在一个多个表格中一次性插入多个insert语句;
- 信息系统的需求视图
- Intro to Makefile
- VS Code使用技巧整理
- Eclipse中修改Web项目的URL访问路径
- caffe初探之-caffe使用Siamese Network 训练网minst数据集
- Windows下配置QT
- udp连接通信demo
- TensorFlow 全网最全学习资料汇总之TensorFlow的技术应用
- Mybatis学习教程—— mapper.xml文件详解
- 导出Excel示例(C++)【设置边框、设置背景色、合并单元格的示例】