我在Windows中有一個MinGW文件夾,並且我沒有在環境變量中設置任何路徑。當我運行以下命令:在Windows 7中運行MinGW gcc編譯器而不設置環境變量
D:\toolchains\MinGW\bin>gcc.exe hw.c -o hw
我得到這個錯誤:
gcc.exe: error: CreateProcess: No such file or directory
據我瞭解,這個問題所造成的,我沒有這個路徑添加到環境變量。如何在不向環境變量添加此路徑的情況下解決此問題,因爲我打算從Python腳本運行此命令。
您只需調用'D:\ toolchains \ MinGW \ bin \ gcc.exe',而不是調用'gcc.exe'。只要您提供gcc的完整路徑,您甚至不需要在MinGW安裝目錄中。 – Tim
@TimF當我這樣做時,我得到了同樣的錯誤:( –
好吧,對不起,那麼它是gcc,沒有找到hw.c.所以無論你從hw.c文件夾執行這個命令,或者你給絕對或相對於hw.c的路徑例如'D:\ toolchains \ MinGW \ bin \ gcc.exe D:\ path \ to \ hw.c -o hw' – Tim