Main.cpp:2:29:fatal error:opencv 2/opencv.hpp:No such file or directory c++

ltskdhd1  于 2023-10-24  发布在  其他
关注(0)|答案(1)|浏览(99)

我知道这个问题已经问过了,但我不能理解他们的解释。我是完全新的编码,帮助如果你可以。
这是我的文件图像:

这是我的任务jason文件:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "`pkg-config",
                "--cflags",
                "--libs",
                "opencv4`"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: /usr/bin/g++"
        }
    ]
}

下面是我的CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)

project(ObjectDetection)

set(OpenCV_DIR C:/Users/prana/OneDrive/Desktop/last_attempt/opencv)
find_package(OpenCV REQUIRED)

add_executable(${PROJECT_NAME} src/Main.cpp)

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
zphenhs4

zphenhs41#

尝试添加/build进行更改

set(OpenCV_DIR C:/Users/prana/OneDrive/Desktop/last_attempt/opencv)

set(OpenCV_DIR C:/Users/prana/OneDrive/Desktop/last_attempt/opencv/build)

相关问题