libsdl-org / SDL_image

Image decoding for many popular formats for Simple Directmedia Layer.
zlib License
572 stars 186 forks source link

Add libwebpdemux to .pc file for static builds #473

Closed sharkwouter closed 4 weeks ago

sharkwouter commented 4 weeks ago

This is required to successfully link to SDL2_image if it was build statically while not using the vendored version of libwebp.

Here is an example of this error: https://github.com/sharkwouter/oceanpop/actions/runs/11243696277/job/31260185313

[ 85%] Linking CXX executable oceanpop
/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld: /usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/lib/libSDL2_image.a(IMG_webp.c.obj): in function `IMG_InitWEBP':
(.text+0xec): undefined reference to `WebPDemuxInternal'
/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld: (.text+0xf4): undefined reference to `WebPDemuxInternal'
/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld: (.text+0xfc): undefined reference to `WebPDemuxGetFrame'
/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld: (.text+0x100): undefined reference to `WebPDemuxGetI'
/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld: (.text+0x104): undefined reference to `WebPDemuxGetFrame'
/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld: (.text+0x108): undefined reference to `WebPDemuxGetI'
/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld: (.text+0x118): undefined reference to `WebPDemuxDelete'
/usr/local/vitasdk/bin/../lib/gcc/arm-vita-eabi/10.3.0/../../../../arm-vita-eabi/bin/ld: (.text+0x11e): undefined reference to `WebPDemuxDelete'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/oceanpop.dir/build.make:449: oceanpop] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:89: CMakeFiles/oceanpop.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2

I'm using pkgconf in CMake for linking basically like this:

include(FindPkgConfig)
pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image)
target_link_libraries(${PROJECT_NAME} PRIVATE
        ${SDL2_IMAGE_STATIC_LIBRARIES}
)

Applying this change fixed the linking errors for me.

I do not know if this also applies to SDL3_image, since I only use SDL2_image.

sezero commented 4 weeks ago

Yes, autotools seem to do it right, cmake had this missing. Merging.

@madebr: SDL3image possibly need this too? Leaving that to you.

madebr commented 4 weeks ago

See a010117fee88255a32492ae9a43e93a213d608ec