launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [
{
"name": "LD_LIBRARY_PATH",
"value": "$LD_LIBRARY_PATH:/media/a/DATA/Myopencv/lib"
}
],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"preLaunchTask": "build_cpp",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "build_cpp",
"command": "/usr/bin/g++",
"args": [
"${file}",
"-fdiagnostics-color=always",
"-g",
"-std=c++11",
"-I", "/media/a/DATA/Myopencv/include/opencv4",
"-L", "/usr/local/lib",
"-L/usr/local/lib",
"-L", "/media/a/DATA/Myopencv/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_photo",
"-l", "opencv_videoio",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "编译器: /usr/bin/cpp"
},
]
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/**",
"/usr/lib/x86_64-linux-gnu/**",
"/media/a/DATA/Myopencv/include",
"/media/a/DATA/Myopencv/include/opencv4/opencv2",
"/media/a/DATA/Myopencv/include/opencv4"
],
"defines": [],
"compilerPath": "/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
main.cpp
#include
//#include
#include
#include
int main()
{
cv::Mat img = cv::imread("test.jpg");
cv::imshow("xxx",img);
cv::waitKey(0);
return 0;
}