CMAKE kann nicht finden_package (openCV), OpenCV mit VCPKG unter Linux installiertC++

Programme in C++. Entwicklerforum
Anonymous
 CMAKE kann nicht finden_package (openCV), OpenCV mit VCPKG unter Linux installiert

Post by Anonymous »

Ich habe diese Dateien, die versuchen, eine einfache Anwendung mit OpenCV unter Linux zu erstellen: < /p>

Code: Select all

cmake_minimum_required(VERSION 3.29)
project(opencv_app)

# Enable C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Enable vcpkg manifest mode
if(DEFINED ENV{VCPKG_ROOT})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")

# Set a suitable triplet for Linux (adjust if using a different architecture)
set(VCPKG_TARGET_TRIPLET "x64-linux" CACHE STRING "")
endif()

message(STATUS "Using vcpkg toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
message(STATUS "Using vcpkg triplet: ${VCPKG_TARGET_TRIPLET}")

# Add executable
add_executable(opencv_app main.cpp)

# Find OpenCV package via vcpkg
find_package(OpenCV REQUIRED)
target_link_libraries(opencv_app PRIVATE ${OpenCV_LIBS})
target_include_directories(opencv_app PRIVATE ${OpenCV_INCLUDE_DIRS})
< /code>
und vcpkg.json: < /p>
{
"name": "opencv_app",
"version": "0.1.0",
"dependencies": [
{
"name": "opencv",
"default-features": false,
"features": [ "jpeg" ]
}
]
}
< /code>
Und ich versuche es mit diesem Befehl zu erstellen: < /p>
cmake -B build -S .
< /code>
, aber ich erhalte diesen Fehler: < /p>
cmake -B build -S .
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 13.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using vcpkg toolchain file: /media/r/Data/locals/vcpkg/scripts/buildsystems/vcpkg.cmake
-- Using vcpkg triplet: x64-linux
CMake Error at CMakeLists.txt:24 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.

Could not find a package configuration file provided by "OpenCV" with any
of the following names:

OpenCVConfig.cmake
opencv-config.cmake

Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files.  If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.

-- Configuring incomplete, errors occurred!
Was ist das Problem und wie ich es beheben kann?>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post