日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

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

發布時間:2025/3/21 c/c++ 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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++环境的全部內容,希望文章能夠幫你解決所遇到的問題。

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