From f428a642e3d8d9cdec8905771cf0efac48c1704e Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Wed, 23 Nov 2022 07:41:10 +0000 Subject: [PATCH] libyuv: fix libyuv.so underlinking When `libyuv` is built with `jpeg` support it does not directly link `libjpeg` in any form. As a result dynamic loading of the library fails as: >>> import pillow_avif._avif Traceback (most recent call last): File "", line 1, in ImportError: /usr/lib/libyuv.so: undefined symbol: jpeg_resync_to_restart We can reproduce the same problem at build time if we build `libyuv` with `LDFLAGS=-Wl,--no-undefined`: [ 99%] Linking CXX executable yuvconstants ld: CMakeFiles/yuv_shared.dir/source/mjpeg_decoder.cc.o: in function `libyuv::MJpegDecoder::MJpegDecoder()': mjpeg_decoder.cc:(.text+0xfc): undefined reference to `jpeg_resync_to_restart' ld: mjpeg_decoder.cc:(.text+0x136): undefined reference to `jpeg_std_error' ld: mjpeg_decoder.cc:(.text+0x194): undefined reference to `jpeg_CreateDecompress' The change links `libgpeg` against `libyuv` itself to make it a self-contained library. This fixes both loading if the library itself and fixes linking of the library against other binaries without explicit need for passing `-ljpeg`. Change-Id: I044acb3799920e1536bdb3388442a40d4839348b Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4050883 Reviewed-by: Frank Barchard Reviewed-by: Mirko Bonadei Commit-Queue: Frank Barchard --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea45a5ed0..bc6416855 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ TARGET_LINK_LIBRARIES ( yuvconstants ${ly_lib_static} ) find_package ( JPEG ) if (JPEG_FOUND) include_directories( ${JPEG_INCLUDE_DIR} ) - target_link_libraries( yuvconvert ${JPEG_LIBRARY} ) + target_link_libraries( ${ly_lib_shared} ${JPEG_LIBRARY} ) add_definitions( -DHAVE_JPEG ) endif()