Makefile的学习
生活随笔
收集整理的這篇文章主要介紹了
Makefile的学习
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 Makefile
就這樣理解,幫我們對程序進行編譯,我們每次gcc g++啥的很麻煩
?
?
?
?
?
?
?
2?舉例子
我這里有3個文件first.c second.c third.c
first.c文件如下
#include <stdio.h> int add(int a, int b) {return a; }second.c文件如下
int sub(int a, int b) {return a - b; }third.c文件如下
int main() {int sum = add(1, 2);printf("sum is %d\n", sum);int sub = sub(5, 1);printf("sub is %d\n", sub);return 0; }我們編寫Makefile文件,一點要注意這里的名字一定是大寫開頭,叫Makefile
all:test first.o:first.cgcc -c first.c -o first.o second.o:second.cgcc -c second.c -o second.o third.o:third.cgcc -c third.c -o third.o test:first.o second.o third.ogcc -o test first.o second.o third.o沒有寫完,下次在寫。
總結
以上是生活随笔為你收集整理的Makefile的学习的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux之setsid命令
- 下一篇: 剑指offer之反转链表