PR #22559 opened by mpartrid URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22559 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22559.patch
Probe the zlib pkg-config link flags to detect whether the Windows import library is named z.lib or zlib.lib, and use that when rewriting -lz for MSVC-style linkers. Also make the non-pkg-config zlib fallback try both names explicitly so configure works with either z.lib or zlib.lib. >From 81898af6432d3385686acf49bb1c4733a3560f21 Mon Sep 17 00:00:00 2001 From: Michael Partridge <[email protected]> Date: Fri, 20 Mar 2026 14:30:20 +1030 Subject: [PATCH] configure: support z.lib and zlib.lib for zlib on MSVC-style linkers Probe the zlib pkg-config link flags to detect whether the Windows import library is named z.lib or zlib.lib, and use that when rewriting -lz for MSVC-style linkers. Also make the non-pkg-config zlib fallback try both names explicitly so configure works with either z.lib or zlib.lib. --- configure | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 8f9fb04115..9b72de3c3a 100755 --- a/configure +++ b/configure @@ -837,6 +837,10 @@ is_in(){ return 1 } +msvc_style_linker(){ + is_in $ld_type msvc icl lld-link +} + # The cfg loop is very hot (several thousands iterations), and in bash also # potentially quite slow. Try to abort the iterations early, preferably without # calling functions. 70%+ of the time cfg is already done or without deps. @@ -1663,6 +1667,32 @@ check_pkg_config(){ eval add_cflags \$${name}_cflags } +probe_msvc_zlib_libname(){ + log probe_msvc_zlib_libname + zlib_msvc_lib=zlib.lib + + msvc_style_linker || return 0 + test_cmd $pkg_config --exists --print-errors zlib || return 0 + + zlib_pkg_libs=$($pkg_config --libs $pkg_config_flags zlib) || return 0 + is_in -lz $zlib_pkg_libs || return 0 + + for zlib_pkg_lib in $zlib_pkg_libs; do + case $zlib_pkg_lib in + -L*) + zlib_pkg_libdir=${zlib_pkg_lib#-L} + if test -f "$zlib_pkg_libdir/z.lib"; then + zlib_msvc_lib=z.lib + return 0 + elif test -f "$zlib_pkg_libdir/zlib.lib"; then + zlib_msvc_lib=zlib.lib + return 0 + fi + ;; + esac + done +} + check_pkg_config_cpp(){ log check_pkg_config_cpp "$@" name="$1" @@ -5137,7 +5167,7 @@ msvc_common_flags(){ -mthumb) ;; -march=*) ;; -mfp16-format=*) ;; - -lz) echo zlib.lib ;; + -lz) echo ${zlib_msvc_lib:-zlib.lib} ;; -lx264) echo libx264.lib ;; -lstdc++) ;; -l*) echo ${flag#-l}.lib ;; @@ -7193,8 +7223,10 @@ if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then fi fi +enabled zlib && msvc_style_linker && probe_msvc_zlib_libname enabled zlib && { check_pkg_config zlib zlib "zlib.h" zlibVersion || - check_lib zlib zlib.h zlibVersion -lz; } + { zlib_msvc_lib=z.lib; check_lib zlib zlib.h zlibVersion -lz; } || + { zlib_msvc_lib=zlib.lib; check_lib zlib zlib.h zlibVersion -lz; }; } enabled bzlib && check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2 enabled lzma && check_lib lzma lzma.h lzma_version_number -llzma -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
