* [FFmpeg-devel] [PATCH] configure: use proper Windows-style static library naming (PR #20220)
@ 2025-08-11 21:28 Kacper Michajłow
0 siblings, 0 replies; only message in thread
From: Kacper Michajłow @ 2025-08-11 21:28 UTC (permalink / raw)
To: ffmpeg-devel
PR #20220 opened by Kacper Michajłow (kasper93)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20220
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20220.patch
On Windows, static libraries are typically named with a .lib extension.
An exception to this is MinGW targets, which are treated as a distinct
target-os.
Using Windows-style naming allows Clang to be used as the linker driver,
instead of invoking link or lld-link directly. The latter approach
requires manually specifying standard libraries, which may be
error-prone or incomplete.
This change also improves support for LTO and sanitizer builds, where
it's significantly easier to let the compiler driver manage the
necessary linker flags.
It fixes issues where Clang is asked to `-lavcodec`, which gets passed
to the linker as avcodec.lib, resulting in an error like:
lld-link: error: could not open 'avcodec.lib': no such file or directory
This happens because `libavcodec.a` were unexpectedly generated, not
`avcodec.lib` expected by tooling.
Additionally, using Clang (not CL) is simplified, as it does not use
autolinking like MSVC/Clang-CL does. Now `--ld=clang` can be used to add
all the required libraries. Previously, building with Clang was only
possible by using `--ld=lld-link` and manually specifying system
dependencies in `extra-ldflags`.
Note that this doesn't affect mingw build. MSVC builds work the same,
because there libraries are passed as files directly to linker command.
This also removes LD_LIB from Win32/64 target as there is one type of
.lib in practice. We cannot build both shared and static as noted by the
next line.
----
Originally posted on ML:
https://ffmpeg.org/pipermail/ffmpeg-devel/2025-June/345518.html
Fixes:
https://fate.ffmpeg.org/report.cgi?slot=arm64-clang-msvc&time=20250721031410
https://fate.ffmpeg.org/report.cgi?slot=arm64-clang-msvc-shared&time=20250721031502
https://fate.ffmpeg.org/report.cgi?slot=amd64-clang-msvc&time=20250721031613
https://fate.ffmpeg.org/report.cgi?slot=amd64-clang-msvc-asan&time=20250721031707
https://fate.ffmpeg.org/report.cgi?slot=amd64-clang-msvc-shared&time=20250721031619
From 234baa21d51a093147d06fde7e70dfa99c53e631 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <kasper93@gmail.com>
Date: Sun, 3 Aug 2025 20:59:23 +0200
Subject: [PATCH] configure: use proper Windows-style static library naming
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
On Windows, static libraries are typically named with a .lib extension.
An exception to this is MinGW targets, which are treated as a distinct
target-os.
Using Windows-style naming allows Clang to be used as the linker driver,
instead of invoking link or lld-link directly. The latter approach
requires manually specifying standard libraries, which may be
error-prone or incomplete.
This change also improves support for LTO and sanitizer builds, where
it's significantly easier to let the compiler driver manage the
necessary linker flags.
It fixes issues where Clang is asked to `-lavcodec`, which gets passed
to the linker as avcodec.lib, resulting in an error like:
lld-link: error: could not open 'avcodec.lib': no such file or directory
This happens because `libavcodec.a` were unexpectedly generated, not
`avcodec.lib` expected by tooling.
Additionally, using Clang (not CL) is simplified, as it does not use
autolinking like MSVC/Clang-CL does. Now `--ld=clang` can be used to add
all the required libraries. Previously, building with Clang was only
possible by using `--ld=lld-link` and manually specifying system
dependencies in `extra-ldflags`.
Note that this doesn't affect mingw build. MSVC builds work the same,
because there libraries are passed as files directly to linker command.
This also removes LD_LIB from Win32/64 target as there is one type of
.lib in practice. We cannot build both shared and static as noted by the
next line.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
---
configure | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/configure b/configure
index 727c3daea8..fa6ed86bd5 100755
--- a/configure
+++ b/configure
@@ -5112,6 +5112,7 @@ probe_cc(){
_depflags='-MMD -MF $(@:.o=.d) -MT $@'
_cflags_speed='-O3'
_cflags_size='-Oz'
+ _ld_lib='-l%'
elif $_cc -V 2>&1 | grep -q Sun; then
_type=suncc
_ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
@@ -5157,7 +5158,7 @@ probe_cc(){
_cc_o='-Fo$@'
_cc_e='-P'
_flags_filter=icl_flags
- _ld_lib='lib%.a'
+ _ld_lib='%.lib'
_ld_path='-libpath:'
# -Qdiag-error to make icl error when seeing certain unknown arguments
_flags='-nologo -Qdiag-error:4044,10157'
@@ -5175,7 +5176,7 @@ probe_cc(){
_ident=$($_cc -flavor gnu --version 2>/dev/null)
_ld_o='-out:$@'
_flags_filter=msvc_flags
- _ld_lib='lib%.a'
+ _ld_lib='%.lib'
_ld_path='-libpath:'
elif VSLANG=1033 $_cc -nologo- 2>&1 | grep -q ^Microsoft || { $_cc -v 2>&1 | grep -q clang && $_cc -? > /dev/null 2>&1; }; then
_type=msvc
@@ -5205,7 +5206,7 @@ probe_cc(){
fi
_cc_o='-Fo$@'
_cc_e='-P -Fi$@'
- _ld_lib='lib%.a'
+ _ld_lib='%.lib'
_ld_path='-libpath:'
_flags='-nologo'
disable stripping
@@ -5992,9 +5993,6 @@ case $target_os in
win32|win64)
disable symver
if enabled shared; then
- # Link to the import library instead of the normal static library
- # for shared libs.
- LD_LIB='%.lib'
# Cannot build both shared and static libs with MSVC or icl.
disable static
fi
@@ -6002,6 +6000,8 @@ case $target_os in
enabled x86_32 && check_ldflags -LARGEADDRESSAWARE
add_cppflags -DWIN32_LEAN_AND_MEAN
shlibdir_default="$bindir_default"
+ LIBPREF=""
+ LIBSUF=".lib"
SLIBPREF=""
SLIBSUF=".dll"
SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-11 21:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-11 21:28 [FFmpeg-devel] [PATCH] configure: use proper Windows-style static library naming (PR #20220) Kacper Michajłow
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git