DPRCode
DPRCode

Reputation: 51

Error: Missing library 'libopencv_gapi.so.4.6.0' and no known rule to make it

I'm trying to include the OpenCV library in my project using CMake, but I'm encountering an error. This is my first time working with CMake, so I'm not sure what could be causing the issue. The error message I'm getting is:


ninja: error: '_deps/opencv-build/lib/libopencv_gapi.so.4.6.0', needed by 'bin/ICTests', missing and no known rule to make it

Here's an abbreviated version of my CMakeLists.txt file without unnecessary comments and paths:

cmake_minimum_required(VERSION 3.12)
project(IC)

set(CMAKE_CXX_STANDARD 11)

find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})

include(FetchContent)
FetchContent_Declare(
        googletest
        URL https://github.com/google/googletest/archive/5376968f6948923e2411081fd9372e71a59d8e77.zip
)
FetchContent_MakeAvailable(googletest)

include(FetchContent)
FetchContent_Declare(
        opencv
        GIT_REPOSITORY https://github.com/opencv/opencv.git
        GIT_TAG        4.6.0
)
FetchContent_GetProperties(opencv)
if (NOT opencv_POPULATED)
    FetchContent_Populate(opencv)
endif ()
FetchContent_MakeAvailable(opencv)

set(SOURCES
        main.cpp
        )

set(HEADERS

        )

add_executable(IC ${SOURCES} ${HEADERS})
target_link_libraries(ImaCrypt ${OPENSSL_CRYPTO_LIBRARY} ${OpenCV_LIBS})

set(SOURCESTESTS
        )

set(HEADERSTESTS
        )

add_executable(ICTests tests/ImaCryptTests.cpp ${SOURCESTESTS} ${HEADERSTESTS})
target_link_libraries(ICTests ${OPENSSL_CRYPTO_LIBRARY} ${OpenCV_LIBS} gtest_main)

I tried manually building the OpenCV library and including it using the find_package() command, but that resulted in a similar error where another file was missing.

Any help in understanding why I'm getting this error and how to resolve it would be greatly appreciated. Thank you!

Upvotes: 4

Views: 496

Answers (0)

Related Questions