記錄一下配置remote-wsl的經歷。
主要參考:
1 https://www.bilibili.com/video/av64680234?from=search&seid=9560371442015557844
2 https://blog.csdn.net/SuGeLaInys/article/details/99934184
目的:為了可以在Linux平台上編譯代碼.
1 假設已經裝過了WSL和Mingw64
2 假設已安裝Remote-WSL(輸入shift+ctrl+x進入extension界面,尋找該擴展)
Win+R,輸入cmd
輸入wsl 進入wsl界面,輸入whereis g++ ;輸入whereis gdb
確認二者均在/usr/bin下,如果不是,在wsl下輸入sudo apt-get install gdb,sudo apt-get install g++
創建文件夾mkdir test2,cd test2
輸入code .進入VsCode界面.
輸入shift+ctrl+p,選擇 C/C++ edit configuration
需要改動的地方:
1 Compiler Path:/usr/bin/g++
2 IntelliSense mode:default
3 Include Path清空
4 Defines添加_DEBUG;_UNICODE;_UNICODE
輸入shift+ctrl+p,選擇tasks:configure default build task-----> 使用模板創建task.json文件----->Others
對生成的.json進行替換:
1 { 2 "version": "2.0.0", 3 "windows": { 4 "options": { 5 "shell": { 6 "executable": "bash.exe", 7 "args": [ 8 "-c" 9 ] 10 } 11 } 12 }, 13 "tasks": [ 14 { 15 "label": "g++ build active file", 16 "type": "shell", 17 "command": "/usr/bin/g++", 18 "args": [ 19 "-g", 20 "${file}", 21 "-o", 22 "${fileDirname}/${fileBasenameNoExtension}" 23 ], 24 "group": { 25 "kind": "build", 26 "isDefault": true 27 } 28 } 29 ] 30 }
可進行debug,F5