From a5ffd09305669c8ddcf812884d20d35ef9d7c669 Mon Sep 17 00:00:00 2001 From: Chandragupt Singh Date: Sun, 18 Oct 2026 07:38:02 +0530 Subject: [PATCH] Stop FFmpeg libs preceding ccx_rust on the link line (#2357) libccx.a propagated its FFmpeg libraries through INTERFACE_LINK_LIBRARIES, so on a plain -DWITH_FFMPEG=ON build they landed on the link line before rust/libccx_rust.a and GNU ld dropped them, leaving undefined avfilter/swscale symbols. Clear that propagation and drop the duplicate EXTRA_FFMPEG_LIBS append in the WITH_HARDSUBX block (WITH_HARDSUBX already forces WITH_FFMPEG). Plain, OCR and hardsubx builds link the same libraries as before; -DWITH_FFMPEG=ON now links. --- src/CMakeLists.txt | 11 ++++++----- src/lib_ccx/CMakeLists.txt | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6f8785ec..7e2648fd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -175,6 +175,12 @@ if (NETWORKING_DEBUG) endif (NETWORKING_DEBUG) add_subdirectory (lib_ccx) +# ccx is STATIC, so CMake propagates its PRIVATE link libraries to consumers as +# $, pinning the FFmpeg libs before rust/libccx_rust.a. GNU ld +# resolves left to right, so rsmpeg's FFmpeg symbols would already be discarded. +# This file lists every dependency explicitly and owns the order (EXTRA_FFMPEG_LIBS). +set_property (TARGET ccx PROPERTY INTERFACE_LINK_LIBRARIES "") + aux_source_directory(${PROJECT_SOURCE_DIR} SOURCEFILE) set (EXTRA_LIBS ${EXTRA_LIBS} ccx) set (EXTRA_LIBS ${EXTRA_LIBS} ${GPAC_LIBRARIES}) @@ -271,11 +277,6 @@ if (PKG_CONFIG_FOUND AND WITH_HARDSUBX) set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${TESSERACT_INCLUDE_DIRS}) set (EXTRA_INCLUDES ${EXTRA_INCLUDES} ${LEPTONICA_INCLUDE_DIRS}) - - # Collect FFmpeg libs for placement after ccx_rust (same reason as WITH_FFMPEG) - set (EXTRA_FFMPEG_LIBS ${EXTRA_FFMPEG_LIBS} ${AVFORMAT_LIBRARIES} - ${AVUTIL_LIBRARIES} ${AVCODEC_LIBRARIES} ${AVFILTER_LIBRARIES} - ${SWSCALE_LIBRARIES}) endif (PKG_CONFIG_FOUND AND WITH_HARDSUBX) add_executable (ccextractor ${SOURCEFILE} ${FREETYPE_SOURCE} ${UTF8PROC_SOURCE}) diff --git a/src/lib_ccx/CMakeLists.txt b/src/lib_ccx/CMakeLists.txt index 1c6a8c74..ede749d2 100644 --- a/src/lib_ccx/CMakeLists.txt +++ b/src/lib_ccx/CMakeLists.txt @@ -60,9 +60,9 @@ endif (WITH_OCR) aux_source_directory ("${PROJECT_SOURCE_DIR}/lib_ccx/" SOURCEFILE) add_library (ccx ${SOURCEFILE} ccx_dtvcc.h ccx_dtvcc.c ccx_encoders_mcc.c ccx_encoders_mcc.h) -# PRIVATE prevents transitive propagation to consumers (ccextractor). -# The parent CMakeLists.txt adds all needed libs explicitly, controlling -# link order so FFmpeg libs appear after ccx_rust (required by GNU ld). +# PRIVATE does not stop propagation here: ccx is STATIC, so CMake still records +# these in INTERFACE_LINK_LIBRARIES as $. The parent clears that +# and owns the link order (FFmpeg must follow ccx_rust for GNU ld). target_link_libraries (ccx PRIVATE ${EXTRA_LIBS}) target_include_directories (ccx PUBLIC ${EXTRA_INCLUDES})