makefile中的多target混亂依賴模式

2021-07-24 09:42:41 字數 443 閱讀 1278

來看個例子, makefile內容為:

test1 test2: test1.cpp test2.cpp

clean:

rm -f test1 test2

這是一種非常懶散的寫法, 雖然可以work:

taoge@localhost desktop>  make clean

rm -f test1 test2

taoge@localhost desktop> make

g++ test1.cpp test2.cpp -o test1

taoge@localhost desktop> ./test1

hello world

但依賴關係很不明朗, 不好! 而且可能導致雜糅鏈結衝突問題。

還是認為直接指定依賴關係吧!

Makefile多檔案編譯

include test.h main main.c makefile makefile obj makefile src eat eat.c eat.h makefile makefile test.c test.htest.件 include includeint testprint 將test...

多目錄工程的 makefile 範例

最近一直在研究makefile 看了網上比較流行的文章 跟我一起寫 makefile 還有一篇是 gnu makefile中文手冊 兩者的關係是前者是後者的子集,連 跟我一起寫 makefile 作者都說了是參考 gnu makefile中文手冊 來寫的,感嘆linux下的開發真的是奧妙無窮,每一項...

多目錄下多檔案 makefile編寫

前面已經分享了單目錄項下多檔案的makefile的編寫,現在來看看多目錄下多檔案makefile的編寫 在做專案時,一般檔案都會分幾個目錄來存放 基本的是 include bin src obj lib tools 這幾個檔案 我先說下我的檔案存放目錄,用ls r可以檢視到所有檔案 include ...