#1319·hiredis

[BUG] libhiredis_ssl missing link to libhiredis on non-Windows platforms

Author: BwL1289Created Dec 12, 2025Updated Dec 13, 2025

On CMake build when building from master, the libhiredis_ssl shared library is not properly linked to libhiredis on non-Windows platforms, causing undefined symbol errors at runtime.

Reproduce:

  • Build hiredis with SSL support on Linux
  • Check library dependencies with ldd libhiredis_ssl.so
  • Observe that libhiredis.so is not listed as a dependency
  • Attempt to use the SSL library in an application

Expected Behavior:

  • libhiredis_ssl.so should be linked against libhiredis.so and all symbols should be resolved.

Actual Behavior:

  • The library has undefined symbols
bash
bash[./lib64/libhiredis_ssl.so.1.2.1-dev]:
    linux-vdso.so.1 (0x0000ffff93294000)
    libssl.so.3 => /usr/local/lib/libssl.so.3 (0x0000ffff930d8000)
    libcrypto.so.3 => /usr/local/lib/libcrypto.so.3 (0x0000ffff92a00000)
    libc.so.6 => /lib64/libc.so.6 (0x0000ffff92832000)
    # ... other dependencies ...
    # MISSING: libhiredis.so

undefined symbol: redisNetClose        (./lib64/libhiredis_ssl.so.1.2.1-dev)
undefined symbol: hiredisAllocFns      (./lib64/libhiredis_ssl.so.1.2.1-dev)
undefined symbol: __redisSetError      (./lib64/libhiredis_ssl.so.1.2.1-dev)
undefined symbol: redisBufferWrite     (./lib64/libhiredis_ssl.so.1.2.1-dev)
undefined symbol: __redisAsyncDisconnect (./lib64/libhiredis_ssl.so.1.2.1-dev)
undefined symbol: redisBufferRead      (./lib64/libhiredis_ssl.so.1.2.1-dev)
undefined symbol: redisProcessCallbacks (./lib64/libhiredis_ssl.so.1.2.1-dev)

Root Cause

  • In CMakeLists.txt, the hiredis_ssl target only links to hiredis on Windows:
cmake
cmakeTARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE OpenSSL::SSL)
IF(WIN32)
    TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE hiredis)
ENDIF()

This leaves non-Windows platforms without the necessary link.

Fix by simply adding an ELSE() clause to ensure hiredis_ssl links to hiredis on all platforms:

cmake
...
cmakeTARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE OpenSSL::SSL)
IF(WIN32)
    TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE hiredis)
ELSE()
    TARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE hiredis)
ENDIF()

Or more simply, remove the platform-specific conditional entirely:

cmake
cmakeTARGET_LINK_LIBRARIES(hiredis_ssl PRIVATE OpenSSL::SSL hiredis)