ubuntu vscode 配置opencv3.0_ubuntu下配置vscode的c++环境
本文主要是寫的關于在ubuntu18.04下面配置c++版的vscode
本文教程來自于vscode官網
1.首先確保本機已經安裝c++
然后安裝gdb
sudo apt-get update sudo apt-get install build-essential gdb2.建立項目
mkdir projects cd projects mkdir helloworld cd helloworld code .在項目中新建一個main.cpp,hello world
3.在vscode的界面菜單中選擇Terminal > Configure Default Build Task再選擇C/C++: g++ build active file,下面是task.json正確文件的內容
{"version": "2.0.0","tasks": [{"type": "shell","label": "g++ build active file","command": "/usr/bin/g++","args": ["-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}"],"options": {"cwd": "/usr/bin"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true}}] }只需要把我們已經有的task.json寫的和上面相同即可
驗證一下自己的task.json是否有寫正確,換到main.cpp的編輯界面,在vscode的界面中找到Terminal->Run Build Task
查看是否生成好了編譯好的文件
4.配置launch.json
在界面中選擇Run > Add Configuration...,然后在下拉列表中選擇C++ (GDB/LLDB)
g++ build and debug active file
以下是launch.json
{"version": "0.2.0","configurations": [{"name": "g++ build and debug active file","type": "cppdbg","request": "launch","program": "${fileDirname}/${fileBasenameNoExtension}","args": [],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [],"externalConsole": false,"MIMode": "gdb","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}],"preLaunchTask": "g++ build active file","miDebuggerPath": "/usr/bin/gdb"}] }Run > Start Debugging現在就可以debug了
5.c++的其他配置
Ctrl+Shift+P然后選擇C/C++: Edit Configurations (UI)
{"configurations": [{"name": "Linux","includePath": ["${workspaceFolder}/**"],"defines": [],"compilerPath": "/usr/bin/gcc","cStandard": "c11","cppStandard": "c++17","intelliSenseMode": "clang-x64"}],"version": 4 }到這里就結束!
tips:在debug的時候出錯could not find the task 'g++ active file'
只需要更改tasks.json 中的 label 字段與 launch.json 中的 preLaunchTask字段保持相同即可
總結
以上是生活随笔為你收集整理的ubuntu vscode 配置opencv3.0_ubuntu下配置vscode的c++环境的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: comsol积分函数_怎样在COMSOL
- 下一篇: mysql post 中文乱码_mysq