fatal error: 'opencv2/opencv.hpp' file not found in macOS VSCode

Viewed 124

I plan to use opencv in vscode on macos. I have configured my c_cpp_properties.json,launch.json and task.json c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/local/Cellar/opencv/4.5.3_2/include/opencv4/**",
                "/usr/local/Cellar/opencv/4.5.3_2/lib"
            ],
            "defines": [],
            "macFrameworkPath": [],
            "compilerPath": "/usr/local/bin/gcc-11",
            "cStandard": "gnu17",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "macos-gcc-x64"
        }
    ],
    "version": 4
}

task.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ 生成活动文件",
            "command": "/usr/bin/clang++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "-I/usr/local/opt/opencv/include/opencv4",
                "-L/usr/local/opt/opencv/lib",
                "-lopencv_core"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}

And the editor also has smart completion when I enter the include path enter image description here But I still get the file not found error, what should I do?

0 Answers
Related