[Mac/Linux] 讓 make 指令顯示更多除錯訊息

[Mac/Linux] 讓 make 指令顯示更多除錯訊息

有時候在執行 make 編譯專案時,

會突然遇到莫名其妙的錯誤,

從簡短的錯誤訊息裡,可能也未必理解問題發生的原因:

make: *** No rule to make target `/test/kernal.zip', needed by `/test/output/dep.zip'.  Stop.

 

有沒有辦法讓 make 指令可以顯示更多資訊呢?

查了一下,可以用make --debug或是make -d

後者通常會顯示更多的資料,類似每個 makefile 的規則都會顯示出來,

像下面是執行make -d的結果:

  Considering target file `publish'.
   File `publish' does not exist.
    Considering target file `/test/output/dep.zip'.
     File `/test/output/dep.zip' does not exist.
      Considering target file `/test/kernal.zip'.
       File `/test/kernal.zip' does not exist.
       Looking for an implicit rule for `/test/kernal.zip'.
       No implicit rule found for `/test/kernal.zip'.
       Finished prerequisites of target file `/test/kernal.zip'.
      Must remake target `/test/kernal.zip'.
make: *** No rule to make target `/test/kernal.zip', needed by `/test/output/dep.zip'.  Stop.

 

這些資訊有可能可以輔助找出錯誤,

不過有時也會因為資訊過多,更難找出有用的資訊。

因此,就當作一個輔助用的除錯技能吧~

 

參考資料:12. Debugging Makefiles – Managing Projects with GNU Make, 3rd Edition [Book]

(本頁面已被瀏覽過 720 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料