本文共 589 字,大约阅读时间需要 1 分钟。
假设应用程序源程序有三个文件main.c,printf.c,printf.h,生成执行文件为helloworld
假如main.c,printf.c,printf.h与makefile在同一目录,则makefile可以如下编写:helloworld : main.o printf.o gcc -o helloworld main.o printf.omain.o : main.c gcc -c main.cprintf.o : printf.c gcc -c printf.cclean: rm main.o printf.o helloworld
假如main.c,printf.c与makefile在同一目录,而printf.h在当前目录的/include下,则makefile可如下编写:
helloworld : main.o printf.o gcc -o helloworld main.o printf.oCFLAGS := -I$(shell pwd)/includemain.o : main.c gcc -c main.c $(CFLAGS)printf.o : printf.c gcc -c printf.c $(CFLAGS)clean: rm main.o printf.o helloworld
转载地址:http://kqigi.baihongyu.com/