这编辑器真难用,动不动就把前面的删了.
新手入门,高手请不吝赐教,自以为是的喷子请留情.
昨天,主要跟着ZLG的Linux开发教程学习了makefile的基本概念,和实际应用差距还比较大,在网上看了"阿波321--编写Makefile"之后,稍微找到了感觉,记录如下.
hello.c程序
#include<stdio.h>
#include "hello1.h"
int main(void)
{
myprintf1();
return 0;
}
hello1.c程序
#include<stdio.h>
#include"hello1.h"
void myprintf1(void)
{
printf("myprint %d!\n",1);
}
hello1.h程序
#ifndef _HELLO_1_H
#define _HELLO_1_H
void myprintf1(void);
#endif
makefile程序
#
main: hello.o hello1.o
gcc -o main hello.o hello1.o
hello.o:hello.c hello1.h
gcc -c hello.c
hello1.o:hello1.c hello1.h
gcc -c hello1.c
make命令之后通过.
又把makefile程序的顺序进行了调整,编译无法通过,总是生不成hello1.o,
改变顺序的makefile程序
#
main: hello.o hello1.o
hello.o:hello.c hello1.h
hello1.o:hello1.c hello1.h
gcc -o main hello.o hello1.o
gcc -c hello.c
gcc -c hello1.c
万事总有规则,我没有搞清makefile的编译规则,所以上面的程序编译通不过.