Skip to content

Commit 84a2900

Browse files
committed
fix link order: put zlib after png/tiff/openexr
Previous link dependency: imgcodecs --> zlib --> libpng this can generate imgcodecs shared lib, until Visual Studio integrated with vcpkg, which will additionally specify LIBPATH, pointing to vcpkg installed zlib (if any), which links the wrong zlib. Fixed link dependency: imgcodecs --> libpng --> zlib in this fixed case, symbols in zlib referenced in libpng will be found in the build-from-source static zlib, instead of the vcpkg one. related discussion: - microsoft/vcpkg#16165 - opencv#17051 - opencv#10576 MSVC linking order reference pages: - https://docs.microsoft.com/en-us/cpp/build/reference/link-input-files?view=msvc-160 for link order - https://docs.microsoft.com/en-us/cpp/build/reference/linking?view=msvc-160 LIB environment variable, for library file searching - https://docs.microsoft.com/en-us/cpp/build/reference/libpath-additional-libpath?view=msvc-160 LIBPATH option, for library file searching
1 parent 6ee23c9 commit 84a2900

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

modules/imgcodecs/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ if(HAVE_WINRT_CX AND NOT WINRT)
1313
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW")
1414
endif()
1515

16-
if(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR)
17-
ocv_include_directories(${ZLIB_INCLUDE_DIRS})
18-
list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
19-
endif()
20-
2116
if(HAVE_JPEG)
2217
ocv_include_directories(${JPEG_INCLUDE_DIR} ${${JPEG_LIBRARY}_BINARY_DIR})
2318
list(APPEND GRFMT_LIBS ${JPEG_LIBRARIES})
@@ -58,6 +53,11 @@ if(HAVE_OPENEXR)
5853
list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES})
5954
endif()
6055

56+
if(HAVE_PNG OR HAVE_TIFF OR HAVE_OPENEXR)
57+
ocv_include_directories(${ZLIB_INCLUDE_DIRS})
58+
list(APPEND GRFMT_LIBS ${ZLIB_LIBRARIES})
59+
endif()
60+
6161
if(HAVE_GDAL)
6262
include_directories(SYSTEM ${GDAL_INCLUDE_DIR})
6363
list(APPEND GRFMT_LIBS ${GDAL_LIBRARY})

0 commit comments

Comments
 (0)