Ubuntu18.04 vscode(c++)配置opencv successful
需要準備的東西:vscode vscode-c++編譯環境 opencv,主要是修改三個文件,launch.json , c_cpp_properties.json , task,json
vscode配置c++網上的教程較多,在這裡就不再贅述。
1,新建一個cpp檔案,儲存。
2,vscode左側方的debug按鈕(小蟲子)–Debug -> Open Configurations -> 開啟備選框 -> C++(GDB/LLDB) -> g++ build and debug active file
3,回到資源管理器(左側欄的第一個圖示)
4上述操作後開啟launch.json檔案並且修改為:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.o",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"preLaunchTask": "build",//也就是新增一個launch之間的任務,任務名為build,這個build就是我們在tasks.json中設定的任務名。
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
5,按鍵ctrl+shift+P,後輸入選擇Configure Task,在備選框中選擇C/C++:cpp build active file選項,則新建一個task.json檔案。
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g", "-std=c++11", "${file}", "-o", "${fileBasenameNoExtension}.o",// 設定動態連結庫
"-I", "/usr/local/include",
"-I", "/usr/local/include/opencv2",
"-I", "/usr/local/include/opencv4",
"-L", "/usr/local/lib",
"-l", "opencv_core",
"-l", "opencv_imgproc",
"-l", "opencv_imgcodecs",
"-l", "opencv_video",
"-l", "opencv_ml",
"-l", "opencv_highgui",
"-l", "opencv_objdetect",
"-l", "opencv_flann",
"-l", "opencv_imgcodecs",
"-l", "opencv_photo",
"-l", "opencv_videoio"
],// 編譯命令引數 }
]
}
6,Ctrl + Shift + P 開啟搜尋框,鍵入c++,會出現備選專案,選擇圖示Edit configurations (JSON)
並且將c_cpp_properties.json修改為:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/local/include", //請確保你的opencv opencv2標頭檔案夾安裝在這個目錄
"/usr/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
opencv安裝的目錄要在/usr/local/include裡面。
可以輸入命令 :
cd /usr/local/include
ls
結果如下:
7,回到測試檔案,F5執行如下
測試程式:
#include <iostream>
#include<opencv2/opencv.hpp>
#include<opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main()
{
cout<<"hello world"<<endl;
VideoCapture capture(0);
while (1)
{
Mat frame;
capture>>frame;
imshow("src",frame);
waitKey(27);
}
}
相關文章
- vscode 配置c++環境VSCodeC++
- ArchLinux配置OpenCV C++環境LinuxOpenCVC++
- VSCode中配置 C/C++ 環境VSCodeC++
- VSCODE 配置 C/C++ 開發環境VSCodeC++開發環境
- VsCode配置C/C++開發環境VSCodeC++開發環境
- VScode中配置C++執行環境VSCodeC++
- OpenCV(c++)-1 安裝和配置OpenCV4.4(Windows+visual studioOpenCVC++Windows
- 把VSCode配置成C/C++開發IDEVSCodeC++IDE
- OpenCV(c++)-1 安裝和配置OpenCV4.4(Windows+visual studio 2019)OpenCVC++Windows
- VScode編譯opencv(Cmake + MinGW)VSCode編譯OpenCV
- C++之OpenCV入門到提高001:使用 Visual Studio2022 配置 OpenCV 環境C++OpenCV
- 配置VSCODEVSCode
- vscode配置VSCode
- vscode 配置c/c++環境,無法生成 *.exe檔案VSCodeC++
- ubuntu18.04配置Jenkins+dockerUbuntuJenkinsDocker
- vscode 基本配置VSCode
- vscode常用配置VSCode
- A successful Git branching modelGit
- 配置QT Mingw & opencvQTOpenCV
- VScode配置xdebug相關配置VSCode
- Linux Ubuntu18.04 安裝配置 clashLinuxUbuntu
- OpenCV4.4.0 安裝測試 Installation & Examination (Ubuntu18.04, Ubuntu 20.04)OpenCVUbuntu
- vscode配置別名VSCode
- Vscode 配置清單VSCode
- vscode之C配置VSCode
- OpenCV之C++經典案例OpenCVC++
- 在ubuntu18.04版本安裝vscode和除錯使用UbuntuVSCode除錯
- Ubuntu18.04深度學習環境配置Ubuntu深度學習
- Visual Studio Code (vscode) 配置C、C++環境/編寫執行C、C++(Windows)【真正的小白版】VSCodeC++Windows
- vscode遠端除錯c++VSCode除錯C++
- 【隨手筆記】OpenCV python+vscode環境搭建筆記OpenCVPythonVSCode
- C++ opencv中的namedWindow和imshowC++OpenCV
- 我的VSCode前端配置VSCode前端
- vscode 外掛配置指北VSCode
- 同步你的 vscode 配置VSCode
- vscode 開發Vue配置VSCodeVue
- 配置環境之vscodeVSCode
- VSCode配置python專案VSCodePython