Issue 584 in webp: pkg-config modules are broken for MSVC if compiled with -DBUILD_SHARED_LIBS=false

432 views
Skip to first unread message

a… via monorail

unread,
Oct 7, 2022, 7:00:22 PM10/7/22
to webp-d...@webmproject.org
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 584 by a...@amyspark.me: pkg-config modules are broken for MSVC if compiled with -DBUILD_SHARED_LIBS=false
https://bugs.chromium.org/p/webp/issues/detail?id=584

What steps will reproduce the problem?
1. Build WebP statically (-DBUILD_SHARED_LIBS=false or unset) with CMake.
2. Use pkg-config to find libwebp. (Do NOT use CMake.)
3. Link your program against libwebp.

What is the expected output? What do you see instead?

I expect a successful linkage. Instead I get, eg. with the Krita WebP impex plugin:

[build] LINK Pass 1: command "C:\PROGRA~1\MIB055~1\2022\Preview\VC\Tools\MSVC\1434~1.318\bin\Hostx64\x64\link.exe /nologo plugins\impex\webp\CMakeFiles\kritawebpimport.dir\kritawebpimport_autogen\mocs_compilation.cpp.obj plugins\impex\webp\CMakeFiles\kritawebpimport.dir\kis_webp_import.cpp.obj /out:bin\kritawebpimport.dll /implib:lib\kritawebpimport.lib /pdb:bin\kritawebpimport.pdb /dll /version:0.0 /machine:x64 /STACK:4194304 /RELEASE /debug /INCREMENTAL /GUARD:CF lib\kritaui.lib E:\krita-win\msvc\i_deps\lib\libwebp.lib E:\krita-win\msvc\i_deps\lib\libwebpdemux.lib lib\kritaimpex.lib lib\kritacolor.lib lib\kritalibbrush.lib lib\kritaimage.lib lib\kritapsdutils.lib lib\kritametadata.lib E:\krita-win\msvc\i_deps\lib\boost_system-vc143-mt-x64-1_80.lib lib\kritawidgets.lib E:\krita-win\msvc\i_deps\lib\KF5Completion.lib lib\kritaflake.lib lib\kritapigment.lib lib\kritamultiarch.lib ws2_32.lib netapi32.lib lib\kritacommand.lib E:\krita-win\msvc\i_deps\lib\Qt5Svg.lib lib\kritaresourcewidgets.lib lib\kritawidgetutils.lib E:\krita-win\msvc\i_deps\lib\KF5ItemViews.lib E:\krita-win\msvc\i_deps\lib\Qt5PrintSupport.lib E:\krita-win\msvc\i_deps\lib\KF5ConfigGui.lib E:\krita-win\msvc\i_deps\lib\KF5GuiAddons.lib E:\krita-win\msvc\i_deps\lib\KF5WidgetsAddons.lib lib\kritaresources.lib E:\krita-win\msvc\i_deps\lib\Qt5Sql.lib lib\kritaplugin.lib E:\krita-win\msvc\i_deps\lib\KF5CoreAddons.lib lib\kritastore.lib lib\kritaglobal.lib E:\krita-win\msvc\i_deps\lib\KF5I18n.lib lib\kritaversion.lib E:\krita-win\msvc\i_deps\lib\Qt5Widgets.lib E:\krita-win\msvc\i_deps\lib\Qt5Concurrent.lib E:\krita-win\msvc\i_deps\lib\gsl.lib E:\krita-win\msvc\i_deps\lib\gslcblas.lib E:\krita-win\msvc\i_deps\lib\KF5ConfigCore.lib E:\krita-win\msvc\i_deps\lib\Qt5Xml.lib E:\krita-win\msvc\i_deps\lib\libpng16.lib E:\krita-win\msvc\i_deps\lib\zlib.lib E:\krita-win\msvc\i_deps\lib\Qt5Multimedia.lib E:\krita-win\msvc\i_deps\lib\Qt5Network.lib E:\krita-win\msvc\i_deps\lib\Qt5Gui.lib E:\krita-win\msvc\i_deps\lib\Qt5Core.lib E:\krita-win\msvc\i_deps\lib\IlmImf-2_5.lib E:\krita-win\msvc\i_deps\lib\Imath-2_5.lib E:\krita-win\msvc\i_deps\lib\Half-2_5.lib E:\krita-win\msvc\i_deps\lib\IexMath-2_5.lib E:\krita-win\msvc\i_deps\lib\IlmThread-2_5.lib E:\krita-win\msvc\i_deps\lib\Iex-2_5.lib E:\krita-win\msvc\i_deps\lib\zlib.lib sharpyuv.lib webpdemux.lib webp.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:plugins\impex\webp\CMakeFiles\kritawebpimport.dir/intermediate.manifest plugins\impex\webp\CMakeFiles\kritawebpimport.dir/manifest.res" failed (exit code 1181) with the following output:
[build] LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/RELEASE' specification
[build] LINK : fatal error LNK1181: cannot open input file 'sharpyuv.lib'

What version of the product are you using? On what operating system?

libwebp v1.2.4-79-g5b01f321, Windows 10 21H2, MSVC 19.34.31823.3


Please provide any additional information below.

This regression happened in changeset Ib4d5c256b8c90afd54b4d7bcdee8df532095422d. The author is forcing a prefix for static libraries under MSVC, which is not then saved inside the .pc.in templates.

For instance, pkgconf returns for libwebp:

❯ E:\krita-win\msvc\i_deps\bin\pkgconf.exe --libs libwebp
-LE:/krita-win/msvc/i_deps/bin/../lib -lsharpyuv -lwebp

which is correct according to libwebp.pc, but in fact the library is called:

❯ dir E:\krita-win\msvc\i_deps\lib\lib*.lib

Directory: E:\krita-win\msvc\i_deps\lib

Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 02/10/2022 19:53 218833140 libANGLE.lib
-a--- 02/10/2022 19:30 1011470 libcrypto.lib
-a--- 02/10/2022 20:46 35410 libde265.lib
-a--- 02/10/2022 19:53 26406 libEGL.lib
-a--- 02/10/2022 19:36 17934 libexpat.lib
-a--- 02/10/2022 19:53 211484 libGLESv2.lib
-a--- 02/10/2022 19:30 4292 libintl.lib
-a--- 02/10/2022 19:44 1649242 libpng16_static.lib
-a--- 02/10/2022 19:44 55894 libpng16.lib
-a--- 07/10/2022 19:23 88242 libsharpyuv.lib
-a--- 02/10/2022 19:30 121986 libssl.lib
-a--- 07/10/2022 19:23 2587682 libwebp.lib
-a--- 07/10/2022 19:23 1190764 libwebpdecoder.lib
-a--- 07/10/2022 19:23 100718 libwebpdemux.lib
-a--- 07/10/2022 19:23 254072 libwebpmux.lib
-a--- 02/10/2022 20:58 8634 libx265.lib

It can be fixed with the simple expedient of interpolating the correct prefix in the .pc.in templates. Here I hotpatched by replacing each entry with e.g.:

`-l@CMAKE_STATIC_LIBRARY_PREFIX@sharpyuv`.

A proper fix should make it a common variable, though, since there's no way to know inside configure_file which one is the active prefix.

--
You received this message because:
1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

jz… via monorail

unread,
Oct 11, 2022, 8:06:40 PM10/11/22
to webp-d...@webmproject.org
Updates:
Owner: jz...@google.com
Status: Accepted

Comment #1 on issue 584 by jz...@google.com: pkg-config modules are broken for MSVC if compiled with -DBUILD_SHARED_LIBS=false
https://bugs.chromium.org/p/webp/issues/detail?id=584#c1

Thanks for the report. I'll try to take a look at it this week.

Git Watcher via monorail

unread,
Oct 20, 2022, 2:26:05 PM10/20/22
to webp-d...@webmproject.org
Updates:
Status: Fixed

Comment #2 on issue 584 by Git Watcher: pkg-config modules are broken for MSVC if compiled with -DBUILD_SHARED_LIBS=false
https://bugs.chromium.org/p/webp/issues/detail?id=584#c2

The following revision refers to this bug:
https://chromium.googlesource.com/webm/libwebp/+/2498209ba9391b526e001f9fe01cba230dd9b10e

commit 2498209ba9391b526e001f9fe01cba230dd9b10e
Author: James Zern <jz...@google.com>
Date: Sat Oct 15 22:54:17 2022

*.pc.in: add lib prefix to lib names w/MSVC

this fixes the library names output after:
9ac25bcb3 CMakeLists.txt,win32: match naming convention used by nmake

before this change:
pkg-config --libs --msvc-syntax \
libwebp libwebpdemux libwebpmux libsharpyuv libwebpdecoder
/libpath:.../lib webpdemux.lib webpmux.lib webp.lib
sharpyuv.lib webpdecoder.lib

after:
pkg-config --libs --msvc-syntax \
libwebp libwebpdemux libwebpmux libsharpyuv libwebpdecoder
/libpath:.../lib libwebpdemux.lib libwebpmux.lib libwebp.lib
libsharpyuv.lib libwebpdecoder.lib

Bug: webp:584
Change-Id: Ic3693b58a40e0ba683333065003b1c00aab0cf48
Fixed: webp:584

[modify] https://crrev.com/2498209ba9391b526e001f9fe01cba230dd9b10e/src/mux/libwebpmux.pc.in
[modify] https://crrev.com/2498209ba9391b526e001f9fe01cba230dd9b10e/sharpyuv/libsharpyuv.pc.in
[modify] https://crrev.com/2498209ba9391b526e001f9fe01cba230dd9b10e/src/libwebp.pc.in
[modify] https://crrev.com/2498209ba9391b526e001f9fe01cba230dd9b10e/src/demux/libwebpdemux.pc.in
[modify] https://crrev.com/2498209ba9391b526e001f9fe01cba230dd9b10e/src/libwebpdecoder.pc.in
[modify] https://crrev.com/2498209ba9391b526e001f9fe01cba230dd9b10e/CMakeLists.txt

Kleis Auke Wolthuizen

unread,
Oct 22, 2022, 1:24:24 PM10/22/22
to WebP Discussion, Git Watcher via monorail, no_r...@monorail-prod.appspotmail.com
The above commit seems to break the build of OSS-Fuzz projects that build libwebp via Autotools with:
```
/usr/bin/ld: cannot find -l@lib_prefix@webp
/usr/bin/ld: cannot find -l@lib_prefix@sharpyuv
```

See:

James Zern

unread,
Oct 24, 2022, 7:22:06 PM10/24/22
to webp-d...@webmproject.org
On Sat, Oct 22, 2022 at 10:24 AM Kleis Auke Wolthuizen <klei...@gmail.com> wrote:
The above commit seems to break the build of OSS-Fuzz projects that build libwebp via Autotools with:
```
/usr/bin/ld: cannot find -l@lib_prefix@webp
/usr/bin/ld: cannot find -l@lib_prefix@sharpyuv
```

See:

Thanks for letting us know. I did forget about autoconf when making this change. It looks like we're missing some build coverage for consuming the pkg-config files.
 
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To view this discussion on the web visit https://groups.google.com/a/webmproject.org/d/msgid/webp-discuss/8d7fa0c0-0191-4f09-b489-15d0b9d802efn%40webmproject.org.

James Zern

unread,
Oct 24, 2022, 7:48:46 PM10/24/22
to webp-d...@webmproject.org
On Mon, Oct 24, 2022 at 4:21 PM James Zern <jz...@google.com> wrote:


On Sat, Oct 22, 2022 at 10:24 AM Kleis Auke Wolthuizen <klei...@gmail.com> wrote:
The above commit seems to break the build of OSS-Fuzz projects that build libwebp via Autotools with:
```
/usr/bin/ld: cannot find -l@lib_prefix@webp
/usr/bin/ld: cannot find -l@lib_prefix@sharpyuv
```

See:

Thanks for letting us know. I did forget about autoconf when making this change. It looks like we're missing some build coverage for consuming the pkg-config files.

This will be fixed after https://chromium-review.googlesource.com/c/webm/libwebp/+/3976735 lands. I'll look at adding some pkg-config tests to our build.

James Zern

unread,
Oct 25, 2022, 6:55:20 PM10/25/22
to webp-d...@webmproject.org
On Mon, Oct 24, 2022 at 4:48 PM James Zern <jz...@google.com> wrote:


On Mon, Oct 24, 2022 at 4:21 PM James Zern <jz...@google.com> wrote:


On Sat, Oct 22, 2022 at 10:24 AM Kleis Auke Wolthuizen <klei...@gmail.com> wrote:
The above commit seems to break the build of OSS-Fuzz projects that build libwebp via Autotools with:
```
/usr/bin/ld: cannot find -l@lib_prefix@webp
/usr/bin/ld: cannot find -l@lib_prefix@sharpyuv
```

See:

Thanks for letting us know. I did forget about autoconf when making this change. It looks like we're missing some build coverage for consuming the pkg-config files.

This will be fixed after https://chromium-review.googlesource.com/c/webm/libwebp/+/3976735 lands. I'll look at adding some pkg-config tests to our build.

I merged this change. I have a few follow up commits, but this should fix those builds. I also added some build coverage to help prevent regressions in the future.
Reply all
Reply to author
Forward
0 new messages