pkgconf issues when trying to configure FFmpeg with libbluray
Hi,
I believe this commit may be causing issues with pkgconf > 1.8 and downstream projects.
In my case, I'm using msys2 to build FFmpeg with libbluray and have built libxml2 and libbluray from their respective git checkouts. On the configure stage, the script errors with libxml2 having undefined references to symbols from libz and liblzma.
To start, I used cmake -B build-32-bit -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/local32 -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_TESTS=OFF
.
The generated .pc file currently has:
prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
modules=1
Name: libXML
Version: 2.12.0
Description: libXML library version2.
Requires: liblzma zlib
Libs: -L${libdir} -lxml2 -liconv -lm -lws2_32
Cflags: -I${includedir}/libxml2 -DLIBXML_STATIC
For libbluray, it's a bit more complicated, so I'll skip to the .pc file:
prefix=/local32
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: libbluray
Description: library supporting Blu-ray playback
Version: 1.3.4
Libs: -L${libdir} -lbluray
Libs.private:
Requires.private: libxml-2.0 >= 2.6
Cflags: -I${includedir} -DLIBXML_STATIC
This results in
$ pkgconf --static --libs libbluray
-lbluray -llzma -lz -lxml2 -liconv -lm -lws2_32
Note the lack of -llzma -lz
after -lxml2
.
Reverting to the commit before, the generated libxml-2.0.pc
looks like:
prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
modules=1
Name: libXML
Version: 2.12.0
Description: libXML library version2.
Requires:
Libs: -L${libdir} -lxml2
Libs.private: -lz -llzma -liconv -lm -lws2_32
Cflags: -I${includedir}/libxml2 -DLIBXML_STATIC
And with that .pc file,
$ pkgconf --static --libs libbluray
-lbluray -lxml2 -lz -llzma -liconv -lm -lws2_32
And that no longer causes any linking errors.
As a few notes, modifying the current version of the .pc file by moving the Requires:
section to Requires.private:
will also work, as it results in the same pkgconf output.
I believe this may also be due to pkgconf trying to be a bit smarter and sorting/deduplicating the output starting from after 1.8, but it seems to be backfiring here. I do not have proper access to pkg-config (from freedesktop) so I cannot easily test the outcome there.