Windows环境VSCode配置OpenCV-项目配置(二)

  1. 修改c_cpp_properties.json

    复制代码
     {
      "configurations": [
        {
          "name": "windows-gcc-x64",
          "includePath": [
            "${workspaceFolder}/**",
            "D:/mingw64/mingw64/include",
            "D:/openCV_win/build/install/include",
            "D:/openCV_win/build/install/include/opencv2"
          ],
          "compilerPath": "D:/mingw64/mingw64/bin/gcc.exe",
          "cStandard": "${default}",
          "cppStandard": "${default}",
          "intelliSenseMode": "windows-gcc-x64",
          "compilerArgs": [
            ""
          ]
        }
      ],
      "version": 4
    }
  2. 修改tasks.json

    复制代码
    {
        "tasks": [
            {
                "type": "cppbuild",
                "label": "C/C++: g++.exe 生成活动文件",
                "command": "D:\\mingw64\\mingw64\\bin\\g++.exe",
                "args": [
                    "-fdiagnostics-color=always",
                    "-g",
                    "${file}",
                    "-o",
                    "${fileDirname}\\${fileBasenameNoExtension}.exe",
                    "-I", "D:/openCV_win/build/install/include/",
                    "-I", "D:/openCV_win/build/install/include/opencv2/",
                    "-L", "D:/openCV_win/build/install/x64/mingw/bin/lib*"
                ],
                "options": {
                    "cwd": "${fileDirname}"
                },
                "problemMatcher": [
                    "$gcc"
                ],
                "group": {
                    "kind": "build",
                    "isDefault": true
                },
                "detail": "调试器生成的任务。"
            }
        ],
        "version": "2.0.0"
    }
  3. launch.json

    复制代码
    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "C/C++ Runner: Debug Session",
          "type": "cppdbg",
          "request": "launch",
          "args": [],
          "stopAtEntry": false,
          "externalConsole": true,
          "cwd": "${workspaceFolder}",
          "program": "${workspaceFolder}\\${fileBasenameNoExtension}.exe",
          "MIMode": "gdb",
          "miDebuggerPath": "gdb",
          "setupCommands": [
            {
              "description": "Enable pretty-printing for gdb",
              "text": "-enable-pretty-printing",
              "ignoreFailures": true
            }
          ]
        }
      ]
    }
  4. 新建test.cpp

    复制代码
     #include <iostream>
    #include <opencv2/opencv.hpp>
    using namespace std;
    
    int main() {
        std::cout << "Hello, World start" << std::endl;
        cv::Mat img = cv::imread("C:/Users/Pictures/nba/724224.jpg");
        cv::imshow("img", img);
        cv::waitKey(0);
        std::cout << "Hello, World end" << std::endl;
        return 0;
    }

如果F5出错

Unexpected GDB output from command "-exec-run".

需要修改mingw64的环境变量到git前

运行效果:

相关推荐
zl_vslam18 小时前
SLAM中的非线性优-3D图优化之李群李代数在Opencv-PNP中的应用(四)
人工智能·opencv·算法·计算机视觉
BestOrNothing_201519 小时前
Git 中新建学习分支 + 暂存修改 + VSCode 可视化查看改动(超详细教程)
git·vscode·版本控制·开发技巧
百***680421 小时前
Node.JS 版本管理工具 Fnm 安装及配置(Windows)
windows·node.js
secondyoung1 天前
Mermaid流程图高效转换为图片方案
c语言·人工智能·windows·vscode·python·docker·流程图
!chen1 天前
Zabbix 配置中文界面、监控告警以及Windows、Linux主/被监控模板
linux·windows·zabbix
qq_316837751 天前
华为CCE k8s 使用nfs-subdir-external-provisioner 创建pvc时自动创建pv
windows·华为·kubernetes
呉師傅1 天前
国产化操作系统---银河麒麟安装步骤(简单介绍)
运维·网络·windows·单片机·电脑
菜鸟学321 天前
opencv代码分析
人工智能·opencv·计算机视觉
百***25611 天前
MySQL 实验1:Windows 环境下 MySQL5.5 安装与配置
windows·mysql·adb
猿来是你_L1 天前
C# Dictionary 转换成 List
windows·c#·list