Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Kacper Michajłow" <code@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH] configure: use proper Windows-style static library naming (PR #20220)
Date: Tue, 12 Aug 2025 00:28:12 +0300 (EEST)
Message-ID: <20250811212812.520E368CC79@ffbox0-bg.ffmpeg.org> (raw)

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".

                 reply	other threads:[~2025-08-11 21:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250811212812.520E368CC79@ffbox0-bg.ffmpeg.org \
    --to=code@ffmpeg.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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