Linux学习笔记——例说makefile 综合案例
1.仅仅有单个C文件
本文将不会阐述freemodbus的详细使用方法,而是以makefile的使用方法为主。
# 指定编译器
CC = gcc # CFLAG包含头文件文件夹
CFLAGS = -g -Wall # 头文件查找路径
INC = -Iport -I../../modbus/rtu \
-I../../modbus/ascii -I../../modbus/include -I../../modbus/tcp # 静态链接库
LDFLAGS =
LDLIBS = -lpthread
# 目标
TARGET = tcpmodbus
# 源文件
SRC = demo.c port/portother.c \
port/portevent.c port/porttcp.c \
../../modbus/mb.c ../../modbus/tcp/mbtcp.c \
../../modbus/functions/mbfunccoils.c \
../../modbus/functions/mbfuncdiag.c \
../../modbus/functions/mbfuncholding.c \
../../modbus/functions/mbfuncinput.c \
../../modbus/functions/mbfuncother.c \
../../modbus/functions/mbfuncdisc.c \
../../modbus/functions/mbutils.c # 源文件编译为目标文件
OBJS = $(SRC:.c=.o) # 链接为可运行文件
$(TARGET): $(OBJS)
[tab]$(CC) $^ -o $@ $(LDFLAGS) $(LDLIBS) # 清除可运行文件和目标文件
clean:
[tab]rm -f $(OBJS)
[tab]rm -f $(TARGET) # 编译规则 增加头文件 $@代表目标文件 $< 代表第一个依赖文件
%.o:%.c
[tab]$(CC) $(CFLAGS) $(INC) -o $@ -c $<
请注意共享库应该插入链接过程中而不是编译过程。
Type 'q' for quit or 'h' for help!
> h
FreeModbus demo application help:
'd' ... disable protocol stack.
'e' ... enabled the protocol stack
's' ... show current status
'q' ... quit applicationr
'h' ... this information
>
Linux学习笔记——例说makefile 综合案例的更多相关文章
- Linux学习笔记——例说makefile 索引博文
0.前言 从学习C语言開始就慢慢開始接触makefile.查阅了非常多的makefile的资料但总感觉没有真正掌握makefile,假设自己动手写一个makefile总认为非常吃力.所以特意借 ...
- [转]Linux学习笔记——例说makefile 头文件查找路径
0.前言 从学习C语言开始就慢慢开始接触makefile,查阅了很多的makefile的资料但总感觉没有真正掌握makefile,如果自己动手写一个makefile总觉得非常吃力.所以特意借助 ...
- Linux学习笔记——例说makefile 头文件查找路径
0.前言 从学习C语言開始就慢慢開始接触makefile,查阅了非常多的makefile的资料但总感觉没有真正掌握makefile,假设自己动手写一个makefile总认为非常吃力.所以特意借 ...
- Linux 学习笔记
Linux学习笔记 请切换web视图查看,表格比较大,方法:视图>>web板式视图 博客园不能粘贴图片吗 http://wenku.baidu.com/view/bda1c3067fd53 ...
- linux —— 学习笔记(汇总)
笔记目录:一.系统知识 和 基本概念 二.常用操作 三.系统管理(内存.设备.服务等管理) ...
- Linux 学习笔记之超详细基础linux命令(the end)
Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 14---------------- ...
- Linux 学习笔记之超详细基础linux命令 Part 13
Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 12---------------- ...
- Linux 学习笔记之超详细基础linux命令 Part 12
Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 11---------------- ...
- Linux 学习笔记之超详细基础linux命令 Part 11
Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 10---------------- ...
随机推荐
- 仔细瞄一下HashMap是怎么干活的
以下分析基于jdk11.0.2 1. 创建HashMap时发生了什么? HashMap(),HashMap(int initialCapacity),HashMap(int initialCapaci ...
- django 报错 no such table: auth_user
需要执行 python3 manage.py makemigrations python3 manage.py migrate 参考:http://arrayoverflow.com/question ...
- 标准C程序设计七---50
Linux应用 编程深入 语言编程 标准C程序设计七---经典C11程序设计 以下内容为阅读: <标准C程序设计>(第7版) 作者 ...
- 这是一份很有诚意的2017 Google I/O大会的汇总 & 解析
前言 在刚过去的凌晨(北京时间 5月18日 1.00-3.00),一年一度的2017年Google I/O大会在美国谷歌山景城海岸线圆形剧场如期举行 Google I/O 大会:Innovation ...
- poj 1274(网络流解二分图的最大匹配)
The Perfect Stall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 22539 Accepted: 100 ...
- BZOJ 2085 [POI2010] Hamsters
题面 Description Tz养了一群仓鼠,他们都有英文小写的名字,现在Tz想用一个字母序列来表示他们的名字,只要他们的名字是字母序列中的一个子串就算,出现多次可以重复计算.现在Tz想好了要出现多 ...
- Oracle8i Internal Services
http://d.hatena.ne.jp/yohei-a/20091017/1255791152 第1回 Oracle8i Internal Services 1人読書会 Oracle 読んだところ ...
- ios使用http来上传图片实现方法
if (parameters) { int genderNumber = 1; self.token = loginToken; self.p ...
- [IOS笔记] - 动画animation
//移动 - (IBAction)translation:(id)sender { CABasicAnimation *traslation = [CABasicAnimation animation ...
- xamarin.IOS App闪退日志----crash
一.查找日志文件位置:通过xcode/windows/device/你的IPhone/crash 二.拿到日志可以直接查看,但是日志记录太乱看不懂,需要转换处理,查找.DSYM文件,文件位置:/Use ...