苏嵌//谭晓寅//2018.7.11

 

 

 

今日学习任务

 

1、  了解调试器gdb;(基本调试操作,段错误如何调试)

2、  了解项目管理的方法及重要性;(项目代码目录结构)

3、  熟练掌握makefile基本语法的使用;(目标、依赖、命令)

4、  企业级makefile的编写;(迭代开发)

今日任务完成情况

1234四项任务都已完成

今日开发中出现的问题汇总

 

不理解Makefile文件中函数

今日未解决问题

今日开发收获

1、  掌握了一些基本调试操作

2、  掌握了makefile基本语法的使用

自我评价

按开发规范完成了既定任务

其他


  1、 调试器gdb

[root@localhost0710]# gcc -g sushu.c

[root@localhost0710]# gdb sushu

(gdb) run

(gdb) list

(gdb) break 12

(gdb) next

(gdb) step

(gdb) delete 1

(gdb) countinue

(gdb) finish

(gdb) info break

2、 工程管理器make

[root@localhost cal]# tree

.

|-- Makefile

|-- add

|  |-- Makefile

|  `-- src

|      `-- add.c

|-- div

|  |-- Makefile

|  `-- src

|      `-- div.c

|-- doc

|-- include

|-- main

|  |-- Makefile

|  `-- src

|      `-- main.c

|-- mul

|  |-- Makefile

|  `-- src

|      `-- mul.c

|-- scripts

|  `-- Makefile

`-- sub

   |-- Makefile

   `-- src

       `-- sub.c

 [root@localhostcal]# vim scripts/Makefile

  1CC := gcc

  2CFLAGS := -Wall -O3

  3Libs = -lpthread

  4Target := client

  5Source := $(wildcard src/*.c)

  6Objs := $(patsubst %.c,%.o,$(Source))

  7Modules += main add sub mul div 

  8AllObjs := $(addsuffix /src/*.o,$(Modules))

[root@localhost cal]# vim Makefile

  1include scripts/Makefile

  2

  3modules_make = $(MAKE) -C $(1);

  4modules_clean = $(MAKE) clean -C $(1);

  5

  6.PHONY: all mm mc clean

  7

  8all: $(Target)

  9 

 13mm:

 14        @ $(foreach n,$(Modules),$(call modules_make,$(n)))

 15mc:

 16        @ $(foreach n,$(Modules),$(call modules_clean,$(n)))

 17

 18$(Target) : mm

 19        $(CC) $(CFLAGS) -o $(Target) $(AllObjs) $(Libs)

 21        @ echo $(Target) make done!

 22

 23clean : mc

 24        rm -rf $(Target)

 25        @ echo clean done!

[root@localhost cal]# vim add/Makefile

  1include ../scripts/Makefile

  2

  3all : $(Objs)

  4

  5clean :

 6         rm -rf $(Objs)

[root@localhost cal]# make

make[1]: Entering directory`/root/cal/main'

make[1]: Nothing to be done for `all'.

make[1]: Leaving directory `/root/cal/main'

make[1]: Entering directory `/root/cal/add'

make[1]: Nothing to be done for `all'.

make[1]: Leaving directory `/root/cal/add'

make[1]: Entering directory `/root/cal/sub'

make[1]: Nothing to be done for `all'.

make[1]: Leaving directory `/root/cal/sub'

make[1]: Entering directory `/root/cal/mul'

make[1]: Nothing to be done for `all'.

make[1]: Leaving directory `/root/cal/mul'

make[1]: Entering directory `/root/cal/div'

make[1]: Nothing to be done for `all'.

make[1]: Leaving directory `/root/cal/div'

gcc -Wall -O3 -o calculator main/src/*.oadd/src/*.o sub/src/*.o mul/src/*.o div/src/*.o -lpthread

calculator make done!

[root@localhost cal]# ./calculator

add = 9

sub = 2

mul = 18

div = 2

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值