From 2224a299f09d6c0ca3bd271346dca306f07d2792 Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Fri, 15 Mar 2024 21:19:59 -0400 Subject: [PATCH] GH-40577: [C++] Ensure pkg-config flags include -ldl for static builds (#40578) ### Rationale for this change When linking statically, pkg-config doesn't pick up the new dependency on libdl introduced by https://github.com/apache/arrow/pull/39067 This produces [unresolved symbol errors](https://github.com/apache/arrow/pull/39067#issuecomment-1999218559) ### What changes are included in this PR? Addition of `-ldl` to `ARROW_PC_LIBS_PRIVATE` to ensure linkage to the necessary library ### Are these changes tested? yes ### Are there any user-facing changes? no * GitHub Issue: #40577 Authored-by: Benjamin Kietzman Signed-off-by: Benjamin Kietzman --- cpp/src/arrow/CMakeLists.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index c5449d9956c28..3d1b621db0e9f 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -136,22 +136,21 @@ endif() if(ARROW_ENABLE_THREADING) list(APPEND ARROW_SHARED_PRIVATE_LINK_LIBS Threads::Threads) - list(APPEND ARROW_STATIC_LINK_LIBS Threads::Threads) list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS Threads::Threads) endif() -if(NOT MSVC_TOOLCHAIN) - list(APPEND ARROW_SHARED_INSTALL_INTERFACE_LIBS ${CMAKE_DL_LIBS}) - list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS ${CMAKE_DL_LIBS}) -endif() - set(ARROW_TEST_LINK_TOOLCHAIN ${ARROW_GTEST_GMOCK} ${ARROW_GTEST_GTEST_MAIN}) set(ARROW_TEST_STATIC_LINK_LIBS arrow::flatbuffers arrow_testing_static arrow_static ${ARROW_TEST_LINK_TOOLCHAIN}) set(ARROW_TEST_SHARED_LINK_LIBS arrow::flatbuffers arrow_testing_shared arrow_shared ${ARROW_TEST_LINK_TOOLCHAIN}) -if(NOT MSVC) + +if(CMAKE_DL_LIBS) + list(APPEND ARROW_SHARED_INSTALL_INTERFACE_LIBS ${CMAKE_DL_LIBS}) + list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS ${CMAKE_DL_LIBS}) list(APPEND ARROW_TEST_SHARED_LINK_LIBS ${CMAKE_DL_LIBS}) + list(APPEND ARROW_TEST_STATIC_LINK_LIBS ${CMAKE_DL_LIBS}) + string(APPEND ARROW_PC_LIBS_PRIVATE " -l${CMAKE_DL_LIBS}") endif() # ----------------------------------------------------------------------