VS Code中的OpenCV编译问题

时间:2019-10-09 04:52:44

标签: c++ opencv visual-studio-code

当前,我正在尝试在VS Code环境中运行基于C ++的OpenCV实现,并遇到includePath错误,并且构建结果变为退出状态1。但是,当我在Qt Creator和VS17 Community上运行相同的代码和库组件时,我没有任何错误。

有json配置;

  

prop.json:

<code>
{

        "configurations": [
            {
                "name": "Win32",
                "compilerPath": "C:\\Mingw64\\bin\\x86_64-w64-mingw32-g++.exe",
                "includePath": [
                    "${workspaceRoot}",
                    "C:\\Mingw64\\include",                
                    "C:\\Mingw64\\lib\\gcc\\x86_64-w64-mingw32\\4.9.2\\include",
                    "C:\\Mingw64\\lib\\gcc\\x86_64-w64-mingw32\\4.9.2\\include\\c++",
                    "C:\\Users\\user\\Desktop\\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\\include",
                    "C:\\Users\\user\\Desktop\\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\\include\\opencv2"
                ],
                "defines": [
                    "_DEBUG",
                    "UNICODE",
                    "__GNUC__=5",
                    "__cdecl=__attribute__((__cdecl__))"
                ],
                "intelliSenseMode": "clang-x64",
                "browse": {
                    "path": [
                        "${workspaceRoot}",
                        "C:\\Mingw64\\include",                    
                        "C:\\Mingw64\\lib\\gcc\\x86_64-w64-mingw32\\4.9.2\\include",                
                        "C:\\Mingw64\\lib\\gcc\\x86_64-w64-mingw32\\4.9.2\\include\\c++",                    
                        "C:\\Users\\user\\Desktop\\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\\include",
                        "C:\\Users\\user\\Desktop\\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\\include\\opencv2"
                    ],
                    "limitSymbolsToIncludedHeaders": true,
                    "databaseFilename": ""
                }
            }
        ],
        "version": 4
    }
</code>
  

task.json:

<code>

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "build",
                "type": "shell",
                "command": "g++",
                "args": [
                    "-g",
                    "${file}",
                    "-o", 
                    "${fileBasenameNoExtension}.exe",                
                    "-I","C:\\Users\\user\\Desktop\\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\\include",
                    "-I","C:\\Users\\user\\Desktop\\OpenCV-MinGW-Build-OpenCV-4.1.1-x64\\x64\\mingw\\bin",                
                    "-l","libopencv_calib3d341",
                    "-llibopencv_core341",
                    "-llibopencv_dnn341",
                    "-llibopencv_features2d341",
                    "-llibopencv_flann341",
                    "-llibopencv_highgui341",
                    "-llibopencv_imgcodecs341",
                    "-llibopencv_imgproc341",
                    "-llibopencv_ml341",
                    "-llibopencv_objdetect341",
                    "-llibopencv_photo341",
                    "-llibopencv_shape341",
                    "-llibopencv_stitching341",
                    "-llibopencv_superres341",
                    "-llibopencv_video341",
                    "-llibopencv_videoio341",
                    "-llibopencv_videostab341"
                ],
                "group": {
                    "kind": "build",
                    "isDefault": true
                }
            }
        ]
    }

  

当我尝试使用opencv2 / opencv.hpp标头进行编译时,路径和构建问题均来自此。如果您知道我错过了什么,或者应该添加到该样本中,那将是很棒的选择。

0 个答案:

没有答案