PR #23048 opened by Greisberger Christophe (Greisby)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23048
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23048.patch

Meson-built packages on Windows produce libfoo.a instead of foo.lib 
(mesonbuild/meson#7378), so the naive '-lfoo -> foo.lib' translation in 
msvc_common_flags() fails at link time.
In Conan, lcms is built by Meson, pulled-in by libjxl and configure fails 
finding lcms.

There was already a special case for libx264, this extends to any library.

Introduce _msvc_resolve_lib() which parses `$LDFLAGS` for -LIBPATH: entries and 
searches those directories for the actual library file (foo.lib, libfoo.a, 
libfoo.lib, foo.a), falling back to foo.lib if nothing is found.




>From 45b8c7f0acf80f587d321f3631bb5ebb0d64819d Mon Sep 17 00:00:00 2001
From: Greisberger Christophe <[email protected]>
Date: Fri, 8 May 2026 08:42:29 +0200
Subject: [PATCH] configure: search linker paths for actual library files in
 msvc_common_flags

Meson-built packages on Windows produce libfoo.a instead of foo.lib 
(mesonbuild/meson#7378), so the naive '-lfoo -> foo.lib' translation in 
msvc_common_flags() fails at link time.

Introduce _msvc_resolve_lib() which parses `$LDFLAGS` for -LIBPATH: entries and 
searches those directories for the actual library file (foo.lib, libfoo.a, 
libfoo.lib, foo.a), falling back to foo.lib if nothing is found.

Signed-off-by: Greisberger Christophe <[email protected]>
---
 configure | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 9bce658932..2d6aecd76d 100755
--- a/configure
+++ b/configure
@@ -5180,6 +5180,23 @@ cparser_flags(){
 }
 
 msvc_common_flags(){
+    # Resolve a library name by searching linker paths for actual files.
+    # Meson-built packages on Windows produce libfoo.a instead of foo.lib 
(mesonbuild/meson#7378), so the naive "-lfoo -> foo.lib" fails.
+    # Parse $LDFLAGS for -LIBPATH: entries (set by Conan/env) since test_ld 
splits -L and -l flags into separate subshell invocations.
+    _msvc_resolve_lib(){
+        _name="$1"
+        for _flag in $LDFLAGS; do
+            case $_flag in
+                -LIBPATH:*) _dir="${_flag#-LIBPATH:}" ;;
+                -libpath:*) _dir="${_flag#-libpath:}" ;;
+                *) continue ;;
+            esac
+            for _cand in "${_name}.lib" "lib${_name}.a" "lib${_name}.lib" 
"${_name}.a"; do
+                [ -f "${_dir}/${_cand}" ] && echo "$_cand" && return
+            done
+        done
+        echo "${_name}.lib"
+    }
     for flag; do
         case $flag in
             # In addition to specifying certain flags under the compiler
@@ -5199,9 +5216,8 @@ msvc_common_flags(){
             -march=*)             ;;
             -mfp16-format=*)      ;;
             -lz)                  echo zlib.lib ;;
-            -lx264)               echo libx264.lib ;;
             -lstdc++)             ;;
-            -l*)                  echo ${flag#-l}.lib ;;
+            -l*)                  _msvc_resolve_lib "${flag#-l}" ;;
             -LARGEADDRESSAWARE)   echo $flag ;;
             -L*) [ "$_flags_type" = "link" ] && echo -libpath:${flag#-L} ;;
             -Wl,*)                ;;
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to