问答题X 纠错
(1)在/work目录先新建一个hello2目录,并在该目录下用vi命令创建文件hello1.c、hello2.c、hello.h和Makefile。分别输入如下内容。
文件hello1.c
//hello1.c
#include
intmain()
{
printf("WelcomeEmdoor!\n");
test2();
return1;
}
文件hello2.c
//hello2.c
#include"hello2.h"
#include
voidtest2(void)
{
printf("WelcomeEmdoor!–hello2\n");
}
文件hello2.h
//hello2.h
voidtest2(void);
文件makefile
#makefiletestformultifilesprogram
CC=gcc
OFLAGS=
OBJS=hello1.ohello2.o
all:hello
hello:$(OBJS)
$(CC)$(CFLAGS)$^-o$@
hello1.o:hello1.c
$(CC)$(CFLAGS)-c$<-o$@
hello2.o:hello2.c
$(CC)$(CFLAGS)-c$<-o$@
clean:
rm-rfhello*.o
(2) 先后执行如下命令
[root@local]$make
[root@local]$./hello
你可能喜欢
问答题
问答题
问答题
问答题
问答题
问答题
问答题