
安裝 MinGW 並設定好「環境變數」後,就可以利用 Windows PoeweShell 使用 GCC 指令編譯 C 或 C++ 程式,編譯 C++ 程式的指令為 g++ ,例如以下編譯 demo.cpp

無聲無息跳到下一行,表示編譯成功,繼續利用 dir 指令列出所有檔案,可以發現多了 a.exe ,也就是 demo.cpp 已經編譯為執行程式 a.exe

繼續輸入 ./a.exe ,就可以執行 demo.cpp 的程式。

如果要編譯成指定的執行檔案名稱,需要在編譯時加上參數 -o ,後面加上指定的執行檔案名稱,例如底下為 dmeo

編譯完成,可以看到當下目錄下多了跟 a.exe 相當大小的 demo.exe

