苏嵌//郑艳秋//7.11


 

 

 

 

今日学习任务

 

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

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

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

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

今日任务完成情况

 

(详细说明本日任务是否按计划完成,开发的代码量)

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

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

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

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

 

企业级makefile的编写操作不熟练

 

今日未解决问题

 

1、  企业级makefile的编写操作不熟练

2、  总控Makefile、子目录Makefiescripts目录下Makefile的操作

今日开发收获

1、  熟悉了gdb操作的步骤

2、  能够编写简单的makefile文件,了解了其语法的三要素

3、  *代表所有

4、  .o文件能够提高编译效率

5、  在命令前加上@,可消除回显

 

自我评价

 

(是否按开发规范完成既定任务,需要改进的地方,与他人合作效果等)

 

 

老师上课速度有点快,有些跟不上

其他

 

 

代码:

 

#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 div(int a, int b)
{
    return a / b;

}

int mul(int a, int b)
{
    return a * b;

}

int sub(int a, int b)
{
    return a - b;

}

 

 

 

企业级makefile:

 

文件结构:

.

|-- 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

 

scriptsMakefile

  1 CC := gcc

  2CFLAGS := -Wall -O3

  3Libs = -lpthread

  4Target := client

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

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

  7Modules += add sub mul divmain

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

主控Makefile

  1 include 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

 10mm:

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

 12mc:

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

 14

 15$(Target) : mm

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

 17        @ echo $(Target) make done!

 18

 19clean : mc

 20        rm -rf $(Target)

子目录Makefile

  1 include ../scripts/Makefile

  2

  3all : $(Objs)

  4

  5clean :

 6         rm -rf $(Objs)

在进行其他工程文件编写时只需改动目录即可

 


猜你喜欢

转载自blog.csdn.net/qq_41366381/article/details/81006212