Cmake can't find Opencv4 dependencies using vcpkg

27 views Asked by At

Steps to reproduce:

git clone https://github.com/microsoft/vcpkg
.\vcpkg\bootstrap-vcpkg.bat
.\vcpkg\vcpkg.exe install opencv4 --triplet=x64-windows-static
cmake -DCMAKE_TOOLCHAIN_FILE=.\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static .
cmake --build build --config Release 

This command fails, saying:

LINK : fatal error LNK1181: cannot open input file '..\vcpkg\packages\opencv4_x64-windows-static\lib\jpeg.lib' [D:<myfolder>]

The linker appears to be looking in the wrong directory for jpeg.lib, because this file does actually exist in

.\vcpkg\packages\libjpeg-turbo_x64-windows-static\lib\

My `CMakelists.txt file looks like:

cmake_minimum_required(VERSION 3.20)

project(Analysis)
set(CMAKE_BUILD_TYPE "Release")

set(CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/vcpkg/packages")

set(OpenCV_DIR "${PROJECT_SOURCE_DIR}/vcpkg/packages/opencv4_x64-windows-static/share/opencv4/")
set(TIFF_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/vcpkg/packages/tiff_x64-windows-static/include")
set(TIFF_LIBRARY "${PROJECT_SOURCE_DIR}/vcpkg/packages/tiff_x64-windows-static/lib/tiff.lib")

find_package(OpenCV REQUIRED)
find_package(TIFF REQUIRED) 
... (set up executables)

How can I fix the linker here?

0

There are 0 answers