Skip to content

Problems with Linking avif in Visual Studio #26747

@Burnside999

Description

@Burnside999

System Information

OpenCV version: 4.12.0 (d12fa37)
Operating System / Platform: Windows 11 24H2 26100.2605
Compiler & compiler version: Visual Studio 2022 (v143)

Detailed description

I git clone the code directly, and then directly in powershell via cmake ... generated the .sln file, and then when building, I noticed that when compiling the opencv_imgcodecs module, it would fail to compile because the avif library read failed.

图片

I realized that avif.dll is loaded incorrectly in the dependencies, where the correct load should be avif.lib. this file is found by OpenCVFindAVIF.cmake. I don't know if this has something to do with my environment variable configuration or if this is a cmake bug.

图片

Related Code (where AVIF_LIBRARY is set):

unset(AVIF_FOUND)
find_package(libavif QUIET)
if(TARGET avif)
MARK_AS_ADVANCED(AVIF_INCLUDE_DIR)
MARK_AS_ADVANCED(AVIF_LIBRARY)
SET(AVIF_FOUND TRUE)
GET_TARGET_PROPERTY(AVIF_LIBRARY avif LOCATION)
GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR1 avif INCLUDE_DIRECTORIES)
GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR2 avif INTERFACE_INCLUDE_DIRECTORIES)
set(AVIF_INCLUDE_DIR)
if(AVIF_INCLUDE_DIR1)
LIST(APPEND AVIF_INCLUDE_DIR ${AVIF_INCLUDE_DIR1})
endif()
if(AVIF_INCLUDE_DIR2)
LIST(APPEND AVIF_INCLUDE_DIR ${AVIF_INCLUDE_DIR2})
endif()
else()

Steps to reproduce

git clone https://github.com/opencv/opencv.git
cd opencv
mkdir build
cd build
cmake ..

open opencv.sln
build opencv_imgcodecs

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions