PR #25494 opened by ambitiuswisdom
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25494
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25494.patch

LAME 4.0 introduces two relevant build changes:

- It adds pkg-config support, generating and installing `lame.pc`.
- Its autotools build replaces the bundled mpglib decoder with external 
libmpg123, introducing an additional dependency when decoding support is 
enabled.

FFmpeg currently checks libmp3lame through `require`, passing only `-lmp3lame` 
and the platform's libm flags. This bypasses the newly available pkg-config 
metadata, even when the user specifies `--pkg-config-flags=--static`.

Consequently, detection fails with static LAME 4.0 builds that include decoding 
support. An x86_64 MinGW configuration reproduces undefined references to 
`mpg123_init` and other `mpg123_*` symbols, followed by `ERROR: libmp3lame >= 
3.98.3 not found`.

Try `check_pkg_config` with `lame >= 3.98.3` before the existing `require` 
check. This obtains the compiler flags and dependency libraries from package 
metadata, honors the configured pkg-config options, and saves the resulting 
libraries for subsequent linking. The existing header and symbol checks remain 
in place.

Retain the direct library check as a fallback for older LAME releases that do 
not generate `lame.pc`, as well as other installations without usable 
pkg-config metadata. No platform-specific dependency is added to FFmpeg's 
hard-coded library list or global linker flags.

Validation used x86_64 UCRT64 GCC 16.2.0, pkgconf 3.0.10, LAME 4.0, and mpg123 
1.33.7:

- Reproduced the original undefined-symbol failure with a minimal link test and 
the unmodified configure script.
- With complete package metadata, the modified configure completed successfully 
and preserved `-lmp3lame -lmpg123 -lshlwapi` in `EXTRALIBS-avcodec`, in the 
required order.
- Verified the fallback without `lame.pc` using the LAME import library, and 
using static LAME with explicitly supplied dependencies.
- Confirmed that incomplete metadata and missing static dependencies still 
cause detection to fail.

The tested LAME package's original `lame.pc` omitted its private mpg123 
dependency. Static pkg-config tests therefore used separately corrected 
metadata with `Requires.private: libmpg123`, allowing mpg123's own metadata to 
supply `-lshlwapi`. That packaging correction is separate from this FFmpeg 
change.


>From b4f14c65171c9df3e26d4edc059c8e5592a53dee Mon Sep 17 00:00:00 2001
From: Ruonan <[email protected]>
Date: Tue, 27 Oct 2026 01:57:07 +0800
Subject: [PATCH] configure: use pkg-config for libmp3lame when available

LAME 4.0 adds pkg-config support, generating and installing lame.pc.
Its autotools build also replaces the bundled mpglib decoder with
external libmpg123. Static libmp3lame builds with decoding support
therefore require additional libraries when linking.

The existing check links only against libmp3lame and libm, ignoring
pkg-config metadata and failing with undefined mpg123_* references.

Try pkg-config first to obtain the compiler and linker flags, honoring
the configured pkg-config flags for static dependencies. Keep the
existing library check as a fallback for older LAME releases and other
installations without usable pkg-config metadata.

Signed-off-by: Ruonan <[email protected]>
---
 configure | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 083bd652c49..6fb518795dd 100755
--- a/configure
+++ b/configure
@@ -7304,7 +7304,8 @@ if enabled libmfx; then
 fi
 
 enabled libmodplug        && require_pkg_config libmodplug libmodplug 
libmodplug/modplug.h ModPlug_Load
-enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h 
lame_set_VBR_quality -lmp3lame $libm_extralibs
+enabled libmp3lame        && { check_pkg_config libmp3lame "lame >= 3.98.3" 
lame/lame.h lame_set_VBR_quality ||
+                               require "libmp3lame >= 3.98.3" lame/lame.h 
lame_set_VBR_quality -lmp3lame $libm_extralibs; }
 enabled libmpeghdec       && require_pkg_config libmpeghdec "mpeghdec >= 
3.0.0" mpeghdec/mpeghdecoder.h mpeghdecoder_init
 enabled libmysofa         && { check_pkg_config libmysofa libmysofa mysofa.h 
mysofa_neighborhood_init_withstepdefine ||
                                require libmysofa mysofa.h 
mysofa_neighborhood_init_withstepdefine -lmysofa $zlib_extralibs; }
-- 
2.54.0

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

Reply via email to