這編輯器真難用,動不動就把前面的刪了.
新手入門,高手請不吝賜教,自以爲是的噴子請留情.
昨天,主要跟着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的編譯規則,所以上面的程序編譯通不過.