文件在两个文件夹:
inc/hello.h
main/hello.c, main.c, Makefile
文件内容:
hello.h
void hello(char name[]);
hello.c
#include <stdio.h> void hello(char name[]) { printf("Hello %s!/n", name); }
main.c
#include <stdio.h> #include "../inc/hello.h" // The second int main() { hello("GCC"); printf("Haha Linux Ubuntu!/n"); return 0; }
Makefile
# String declaration objects = main.o hello.o # Command app : $(objects) cc -o app $(objects) main.o : main.c hello.h cc -c main.c hello.o : hello.c stdio.h cc -c hello.c # Search paths vpath %.h /usr/include ../inc # Clean the intermediate files .PHONY : clean clean : rm app $(objects)
posted on 2010-03-17 16:03 yanhc 阅读(208) 评论(0) 编辑 收藏 举报