Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default of SUNDIALS_MATH_LIBRARY incorrect? #229

Open
bjodah opened this issue Nov 17, 2022 · 2 comments
Open

Default of SUNDIALS_MATH_LIBRARY incorrect? #229

bjodah opened this issue Nov 17, 2022 · 2 comments
Assignees
Labels

Comments

@bjodah
Copy link

bjodah commented Nov 17, 2022

I'm updating a build script for sundials and I got some linking errors related to transitioning from USE_GENERIC_MATH to SUNDIALS_MATH_LIBRARY. I noticed that the default value for SUNDIALS_MATH_LIBRARY gets set to "-lm", I think it should read just "m" shouldn't it? But maybe CMake strips leading -l, I haven't actually confirmed that it matters.

defined here:

used here (note that the linking mode is PRIVATE):

docs for target_link_libraries:

excerpt:

A link flag: Item names starting with -, but not -l or -framework, are treated as linker flags. Note that such flags will be treated like any other library link item for purposes of transitive dependencies, so they are generally safe to specify only as private link items that will not propagate to dependents.

that would explain why the link error was in linking a test, no?

[108/409] Linking C executable examples/cvode/serial/cvRoberts_dns_uw
FAILED: examples/cvode/serial/cvRoberts_dns_uw 
: && /usr/bin/gcc-12 -Os -g3 -g -Wl,-rpath-link,/usr/lib/x86_64-linux-gnu examples/cvode/serial/CMakeFiles/cvRoberts_dns_uw.dir/cvRoberts_dns_uw.c.o -o examples/cvode/serial/cvRoberts_dns_uw  -Wl,-rpath,/build/sundials-6.4.1-debug/src/cvode:/build/sundials-6.4.1-debug/src/nvector/serial  src/cvode/libsundials_cvode.so.6.4.1  src/nvector/serial/libsundials_nvecserial.so.6.4.1 && :
/usr/bin/ld: src/cvode/libsundials_cvode.so.6.4.1: undefined reference to `pow'
/usr/bin/ld: src/cvode/libsundials_cvode.so.6.4.1: undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
cmake invocation and output
$ cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/opt/sundials-6.4.1-debug '-DCMAKE_INSTALL_RPATH=/opt/sundials-6.4.
1-debug/lib;/usr/lib/x86_64-linux-gnu' -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DEXAMPLES_ENABLE_C=ON -DEXAMPLES_INSTALL=ON 
-DUSE_GENERIC_MATH=OFF -DENABLE_KLU=ON -DKLU_INCLUDE_DIR=/usr/include/suitesparse -DKLU_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu -DENABLE_LAPACK=ON -DLAPACK_LIBRARIES=/us
r/lib/x86_64-linux-gnu/libopenblas.so -DSUNDIALS_INDEX_SIZE=32 /build/sundials-6.4.1
-- The C compiler identification is GNU 12.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc-12 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- SUNDIALS_GIT_VERSION:
CMake Deprecation Warning at cmake/macros/SundialsCMakeMacros.cmake:65 (message):
  ------------------------------------------------------------------------

  WARNING: The CMake option USE_GENERIC_MATH is deprecated

  Use SUNDIALS_MATH_LIBRARY instead

  ------------------------------------------------------------------------
Call Stack (most recent call first):
  cmake/SundialsDeprecated.cmake:169 (print_warning)
  CMakeLists.txt:145 (include)


-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of int32_t
-- Check size of int32_t - done
-- Using int32_t for indices
-- C standard set to 99
-- C extensions set to ON
-- Performing Test SUNDIALS_C_COMPILER_HAS_SNPRINTF_AND_VA_COPY
-- Performing Test SUNDIALS_C_COMPILER_HAS_SNPRINTF_AND_VA_COPY - Success
-- Performing Test SUNDIALS_C_COMPILER_HAS_MATH_PRECISIONS
-- Performing Test SUNDIALS_C_COMPILER_HAS_MATH_PRECISIONS - Success
-- Performing Test SUNDIALS_C_COMPILER_HAS_ISINF_ISNAN
-- Performing Test SUNDIALS_C_COMPILER_HAS_ISINF_ISNAN - Success
-- Performing Test SUNDIALS_C_COMPILER_HAS_INLINE
-- Performing Test SUNDIALS_C_COMPILER_HAS_INLINE - Success
-- Looking for POSIX timers... found
-- Performing Test COMPILER_HAS_DEPRECATED_MSG
-- Performing Test COMPILER_HAS_DEPRECATED_MSG - Success
-- The Fortran compiler identification is GNU 11.3.0
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /usr/bin/gfortran - skipped
-- Determining Fortran name-mangling scheme... OK
-- Appending C DEBUG flags
-- Appending Fortran DEBUG flags
-- Found KLU: /usr/lib/x86_64-linux-gnu/libklu.so
-- KLU_LIBRARIES:   /usr/lib/x86_64-linux-gnu/libklu.so;/usr/lib/x86_64-linux-gnu/libamd.so;/usr/lib/x86_64-linux-gnu/libcolamd.so;/usr/lib/x86_64-linux-gnu/libbtf.so;
/usr/lib/x86_64-linux-gnu/libsuitesparseconfig.so
-- KLU_INCLUDE_DIR: /usr/include/suitesparse
-- Checking if KLU works... OK
-- Looking for LAPACK libraries... OK
-- LAPACK_LIBRARIES:  /usr/lib/x86_64-linux-gnu/libopenblas.so
-- Checking if LAPACK works with SUNDIALS... OK
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Failed
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Added NVECTOR_SERIAL module
-- Added NVECTOR_MANYVECTOR module
-- Added SUNMATRIX_BAND module
-- Added SUNMATRIX_DENSE module
-- Added SUNMATRIX_SPARSE module
-- Added SUNLINSOL_BAND module
-- Added SUNLINSOL_DENSE module
-- Added SUNLINSOL_PCG module
-- Added SUNLINSOL_SPBCGS module
-- Added SUNLINSOL_SPFGMR module
-- Added SUNLINSOL_SPGMR module
-- Added SUNLINSOL_SPTFQMR module
-- Added SUNLINSOL_KLU module
-- Added SUNLINSOL_LAPACKBAND module
-- Added SUNLINSOL_LAPACKDENSE module
-- Added SUNNONLINSOL_NEWTON module
-- Added SUNNONLINSOL_FIXEDPOINT module
-- Added ARKODE module
-- Added CVODE module
-- Added CVODES module
-- Added IDA module
-- Added IDAS module
-- Added KINSOL module
-- Configuring done
-- Generating done
-- Build files have been written to: /build/sundials-6.4.1-debug
+ cmake --build .
[1/409] Building C object src/sundials/CMakeFiles/sundials_generic_obj_shared.dir/sundials_context.c.o
...

or maybe SUNDIALS_MATH_LIBRARY need to be added to e.g. cvRoberts_dns etc.?

@bjodah bjodah changed the title Default of incorrect? Default of SUNDIALS_MATH_LIBRARY incorrect? Nov 17, 2022
@balos1
Copy link
Member

balos1 commented Nov 17, 2022

What platform/operating system are you seeing this error on?

@bjodah
Copy link
Author

bjodah commented Nov 17, 2022

Ubuntu 22.04

@balos1 balos1 self-assigned this Dec 12, 2022
@balos1 balos1 added the triage label Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants