| |
今日学习任务
|
1. 了解调试器gdb(基本调试操作、段错误调试) 2. 了解项目管理的方法及重要性(项目代码 目录结构) 3. 熟练掌握makefile基本语法的使用(目标、依赖、命令) 4. 企业级makefile的编写(迭代开发)
|
今日任务完成情况
| 今日任务按计划完成 1.了解调试器gdb(基本调试操作、段错误调试) 2.熟练掌握makefile基本语法的使用(目标、依赖、命令) 3.了解项目管理的方法及重要性 |
今日开发中出现的问题汇总
| 1. 企业级makefile中部分编写不太熟练 2. 在gdb中如何使list显示完整代码 |
今日未解决问题
| 对如何使list显示完全代码还是没有理解 |
今日开发收获 | 1. 学会了一些有关gdb调试操作 2. 掌握了makefile语法三要素以及一些细节知识点:*.o表示所有的.o文件;-f用于指定的makefile;写成.o文件可以提高编译效率;加@后,命令不显示在终端上;echo相当于c语言中的printf,输出信息 3. 学会了makefile的简单编写,在makefile中定义变量 企业级makefile的总控Makefile、子目录的makefile、scripts目录下的Makefile和操作时的顺序
|
自我评价
| 今天有点跟不上老师的教学进程,自己对知识点掌握、消化、吸收的不太到位 |
其他
| 无 |
1.#include<stdio.h>
int main()
{
printf("add = %d\n",add(6,3));
printf("sub = %d\n",sub(6,3));
printf("mul = %d\n",mul(6,3));
printf("div = %d\n",div(6,3));
return 0;
}
int add(int a, int b)
{
return a + b;
}
int sub(int a, int b)
{
return a - b;
}
int mul(int a, int b)
{
return a * b;
}
int div(int a, int b)
{
return a / b;
}
2.企业级makefile:
[root@localhost ~]# cd 0711
[root@localhost 0711]# ls
add client div main Makefile mul scripts sub
[root@localhost 0711]# tree
.
|-- Makefile
|-- add
| |-- Makefile
| `-- src
| |-- add.c
| `-- add.o
|-- client
|-- div
| |-- Makefile
| `-- src
| |-- div.c
| `-- div.o
|-- main
| |-- Makefile
| `-- src
| |-- main.c
| `-- main.o
|-- mul
| |-- Makefile
| `-- src
| |-- mul.c
| `-- mul.o
|-- scripts
| `-- Makefile
`-- sub
|-- Makefile
`-- src
|-- sub.c
`-- sub.o
directories, 18 files
[root@localhost 0711]# make
client make done!
[root@localhost 0711]# ./client
add = 9
sub = 3
mul = 18
div = 2
scripts的Makefile
CC := gcc
CFLAGS := -Wall -O3
Libs = -lpthread
Target := client
Source := $(wildcard src/*.c)
Objs := $(patsubst %.c,%.o,$(Source))
Modules += main add sub mul div log
AllObjs := $(addsuffix /src/*.o,$(Modules)
主控的makefile:
include scripts/Makefile
modules_make = $(MAKE) -C $(1);
modules_clean = $(MAKE) clean -C $(1);
.PHONY: all mm mc clean
all: $(Target)
mm:
@ $(foreach n,$(Modules),$(call modules_make,$(n)))
mc:
@ $(foreach n,$(Modules),$(call modules_clean,$(n))) $(Target) : mm
$(CC) $(CFLAGS) -o $(Target) $(AllObjs) $(Libs)
@ echo $(Target) make done!
clean : mc
rm -rf $(Target)
@ echo clean done!
子目录下的makefile:
include ../scripts/Makefile
all : $(Objs)
clean :
rm -rf $(Objs)