ubuntu vscode配置c++opencv环境
时间: 2023-11-10 15:00:57 浏览: 388
在Ubuntu中使用VScode配置C++和OpenCV环境的步骤如下:
首先,安装OpenCV。可以参考引用中提供的链接,按照最新最详细的教程进行安装。
安装VScode。在Ubuntu软件中心或者通过终端使用以下命令安装:
sudo snap install --classic code
打开VScode,并安装C++插件。点击左侧菜单栏的扩展图标,搜索并安装"C++"插件。
配置编译器路径和标准。创建一个名为
.vscode
的文件夹,并在其中创建一个名为c_cpp_properties.json
的文件。将以下内容复制到文件中,并保存:{ "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/**", "/usr/include/x86_64-linux-gnu/sys", "/usr/local/include/opencv4" ], "defines": [], "compilerPath": "/usr/bin/gcc", "cStandard": "gnu17", "cppStandard": "gnu17", "intelliSenseMode": "linux-gcc-x64" } ], "version": 4 }
配置构建任务。创建一个名为
tasks.json
的文件,并将以下内容复制到文件中,并保存:{ "tasks": [ { "type": "cppbuild", "label": "C/C++: g++ build active file", "command": "/usr/bin/g++", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}.out", "`pkg-config","--libs","--cflags","opencv4`" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true } } ], "version": "2.0.0" }
现在,你可以在VScode中编写和运行C++代码,并使用OpenCV库。按下
Ctrl + Shift + B
编译并运行代码。
相关推荐
















