> 最近在搞C語言需要一個編譯工具,Visual Studio很肥,Dev-C++功能少,出個Visual Studio Code 教學當作各位的另一個折衷選擇 ## 安裝C++編譯器 1. [安裝MinGW](https://sourceforge.net/projects/mingw/files/)  2. 安裝完後會跳出視窗選擇要安裝的套件,這裡選擇 base 和 g++,選好後點左上角的 Installation 選 Apply Change 開始安裝。   3. 安裝完後要將 MinGW 的安裝路徑 C:\MinGW\bin 加入系統環境變數。 * 我的電腦 -> 右鍵內容 -> 左邊選單 進階系統設定 -> 進階 環境變數。 * 搜尋:編輯系統環境變數-->環境變數-->Path * 設置完成後記得要重開電腦讓系統環境變數生效。   4. ## 另外一種方法 ### Install C/C++ 1. 安裝C/C++  2. 安裝C/C++ Extension Pack  3. 安裝Code Runner  4. 設定  5. 搜尋 Run code in terminal  6. 執行編譯  ## Debug 模式 1. 選擇Debug  2. 設置中斷點後執行 3. Debug 模式完成 ### Error: "The preLaunchTask 'C/C++: g++.exe build active file' terminated with exit code 1"  * 刪除在同一個資料夾底下的.vscode檔,後重新執行。(後面就保佑成功吧) 1. Delete .vscode folder which is auto generated when 1st time debug 2. Now again debug ( Press F5 or Top right Debug C/C++ File) ### Error: VS Code server for WSL closed unexpectedly 這個問題的產生有很多種可能,下面是我找到的解決方法。 我遇到的問題是WSL與VScode 無法連結 WSL 無法執行 code .  此方法為重新掛載驅動器 1. 開啟WSL 2. `sudo umount /mnt/c` 3. `sudo mount -t drvfs C:\\ /mnt/c` #### 其他方法(看vscode output錯誤)   直接修改上述permmission denied的文件權限即可成功編譯
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up