2019/10/17

Make produces "No such file or directory" error in Cygwin


最近需要裝 Cygwin 來 build code,當裝完後執行 Make 時卻發生找不到 source,一直說 "No such file or directory"。

奇怪的是,source 放在 Make 旁邊時可以找到,但是放在子資料夾或是不同資料夾的話就找不到。本來以為是自己路徑給錯,但仔細檢查後又是對的,用 cat 或 ls 也可以找到相對應的 source。

問了下 Google,就在這篇找到 Hint,用 'whereis make' 看了下 make 的路徑,才發覺用到了別的 toolchain 的 make,而不是 Cygwin 提供的 make。


問題的原因就是我之前裝的 toolchain 裡也有提供 make 的 exe,我也有把這個 toolchain 加進 windows 的 PATH 中,結果我在 Cygwin 中做 make 時就誤用了這個 toolchain 的 make ,我應該使用的是 Cygwin installer 中提供的 make 才對。

我就把這個 toolchain 從 windows PATH 中移除後重開 Cygwin,再用一次 'whereis make' 確定 make 的路徑是 '/usr/bin/make.exe' 。重新 build code 時就沒有問題了。