Skip to content

Commit

Permalink
src/CMakeLists.txt: link libplfit against $MATH_LIBRARY
Browse files Browse the repository at this point in the history
The libplfit library makes use of several math functions (exp, log,
...) , and so should be linked to libm directly when libm is required
for those functions. If it is not, then compilation may succeed
leaving the resulting library underlinked. This can lead to errors
like,

  test_discrete: symbol lookup error: .../src/libplfit.so.0: undefined
  symbol: log

when linking with lld and LDFLAGS="Wl,--as-needed". (The error above
comes from plfit's own test suite.)

Gentoo-bug: https://bugs.gentoo.org/926433
  • Loading branch information
orlitzky committed Mar 8, 2024
1 parent 5b1c99e commit 0559e46
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(PLFIT_CORE_SRCS error.c gss.c kolmogorov.c lbfgs.c mt.c platform.c plfit.c o
add_library(plfit ${PLFIT_CORE_SRCS})
target_include_directories(plfit PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(plfit PROPERTIES SOVERSION 0)
target_link_libraries(plfit ${MATH_LIBRARY})

if(PLFIT_USE_OPENMP AND OPENMP_FOUND)
target_link_libraries(plfit OpenMP::OpenMP_C)
Expand Down

0 comments on commit 0559e46

Please sign in to comment.