搭建了好几次每次都好粗糙。这次终于满意啦~
卸载vs所有的插件
sudo rm -rf $HOME/Library/Application\ Support/Code
sudo rm -rf $HOME/.vscode
配置编译文件tasks.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| { "version": "2.0.0", "tasks": [ { "label": "g++", "type": "shell", "command": "g++", "args": [ "-g", "${file}", "-o", "${fileBasenameNoExtension}.out" ], "problemMatcher": { "owner": "cpp", "fileLocation": ["relative", "${workspaceRoot}"], "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } } } ] }
|
添加“launch.json”文件配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| { "version": "0.2.0", "configurations": [ { "name": "(lldb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/${fileBasenameNoExtension}.out", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "lldb", "preLaunchTask": "g++", "setupCommands": [ { "description": "Enable pretty -printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }
|
快捷键“F5”编译运行。
手动编译快捷键“⇧⌘B”。
参考资料:https://blog.csdn.net/deaidai/article/details/82955010