日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

ubuntu vscode 配置opencv3.0_ubuntu下配置vscode的c++环境

發布時間:2025/3/21 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 gdb

2.建立項目

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++环境的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。