1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00

configure: use proper Windows-style static library naming

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 when compiling
with `clang` rather than `clang-cl`, and manually specifying standard
libraries may be error-prone or incomplete.

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 link `-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` was unexpectedly generated, not
`avcodec.lib` expected by tooling.

Additionally, using `clang` (not `clang-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 those changes doesn't affect mingw build. MSVC builds will
produce .lib static libraries now, but the linking process itself is not
affected, because filenames are passed directly.

To summarize in Windows non-mingw builds:
Static builds now produce `lib/avcodec.lib` instead of `lib/libavcodec.a`.
Shared builds remain unchanged, producing `bin/avcodec.lib` together with
`bin/avcodec-62.dll`.

This also removes setting LD_LIB from Win32/64 target as there is one
type of .lib in practice. We cannot build both shared and static at the
same time as noted by the next line.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
This commit is contained in:
Kacper Michajłow
2025-08-03 20:59:23 +02:00
committed by James Almer
parent b8d5f65b9e
commit 8eca3fa619

11
configure vendored
View File

@@ -5157,7 +5157,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 +5175,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 +5205,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 +5992,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 +5999,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)'