makefile 实例一

工程目录

TEST/Makefile

TEST/main/main.c

TEST/count/hjs_count.c

TEST/count/hjs_count.h

TEST/print/hjs_print.c

TEST/print/hjs_print.h


main.c

main()
{
    hjs_count(2);
    hjs_printf(3);
}


hjs_count.c

#include"stdio.h"
int hjs_count(int a)
{
    for (a = 1; a < 10; a++)
        a = a +2;
    printf("value of a is %d\n",a);
    return 0;
}

hjs_count.h

int hjs_count(int a);


hjs_print.c

#include"stdio.h"

int hjs_printf(int a)
{
    printf("the value is %d",a);
    return 0;
}


hjs_print.h
int hjs_printf(int a)


Makefile

all: main.o hjs_count.o hjs_print.o
    gcc -o test main.o hjs_count.o hjs_print.o
main.o:./main/main.c
    gcc -c ./main/main.c
hjs_count.o:./count/hjs_count.c
    gcc -c ./count/hjs_count.c
hjs_print.o:./print/hjs_print.c
    gcc -c ./print/hjs_print.c

clean:
    rm -rf main.o hjs_count.o hjs_print.o test    


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值