LLNL / sundials

Official development repository for SUNDIALS - a SUite of Nonlinear and DIfferential/ALgebraic equation Solvers. Pull requests are welcome for bug fixes and minor changes.
https://computing.llnl.gov/projects/sundials
BSD 3-Clause "New" or "Revised" License
503 stars 122 forks source link

Default of SUNDIALS_MATH_LIBRARY incorrect? #229

Open bjodah opened 1 year ago

bjodah commented 1 year ago

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.?

balos1 commented 1 year ago

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

bjodah commented 1 year ago

Ubuntu 22.04