具體配置過程如下鏈接:
https://zhuanlan.zhihu.com/p/35178331
但中間出了點問題:CTRL+ALT+n 運行后:
PS D:\C++> cd "d:\C++" ; if ($?) { gcc test.c -o test -std=c11 -lm } ; if ($?) { echo '[Running]' } ; if ($?) { ./test }
gcc : 無法將“gcc”項識別為 cmdlet、函數、腳本文件或可運行程序的名稱。請檢查名稱的拼寫,如果包括路徑,請確保路徑正確,然
后再試一次。
所在位置 行:1 字符: 25
+ cd "d:\C++" ; if ($?) { gcc test.c -o test -std=c11 -lm } ; if ($?) { ...
+ ~~~
+ CategoryInfo : ObjectNotFound: (gcc:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
在Windows PowerShell等中執行 g++ / gcc 都沒有問題。
但在VS code中就無法事變,是環境變量添加的問題嗎? 還沒有解決。
經過進一步思考,感覺還是環境變量沒有添加成功的問題!
問題已經解決:(之前用set可以設置的只是臨時的環境變量,僅在當前DOS窗口有效,所以在VS code一直無法識別g++/gcc)
通過控制面板---用戶賬戶---用戶帳戶---更改我的環境變量
通過編輯用戶變量,將...mingw/bin... 路徑添加進來,就可以正常使用g++/gcc 了。
