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

Error building examples on Linux #603

Open
willidu opened this issue Dec 2, 2024 · 4 comments
Open

Error building examples on Linux #603

willidu opened this issue Dec 2, 2024 · 4 comments

Comments

@willidu
Copy link

willidu commented Dec 2, 2024

I am working on a larger project that use SUNDIALS and want to test its functionality independently. I have tried to build the CXX examples. Most of them work, but some of them do not.

Current Behavior:

Building CVODE CXX examples fail due to undefined references.

Steps To Reproduce:

Fork/clone the repo, checkout v7.0.0. Occurs on master as well
Build SUNDIALS with CMake:

#!/bin/bash
# SUNDIALS
mkdir -p build
mkdir -p install
cd build

cmake_flags="-DCMAKE_INSTALL_PREFIX=../install \
             -DBUILD_STATIC_LIBS=ON \
             -DBUILD_SHARED_LIBS=OFF \
             -DEXAMPLES_INSTALL=ON
             -DEXAMPLES_INSTALL_PATH=../install/examples \
             -DEXAMPLES_ENABLE_CXX=ON"
if [[ "$(uname)" == "Linux" ]]; then
    cmake_flags="$cmake_flags -DCMAKE_C_FLAGS=-fPIC"
fi

cmake $cmake_flags ..
make config=release -j$(nproc)
make install
cd ..
echo "SUNDIALS built."

Build some examples

cd install/examples/nvector/serial
make
./test_nvector_serial 10 0

Output is success.

cd install/examples/cvode/CXX_serial
make

Output (see full output.txt):

~/Git/sundials/install/examples/cvode/CXX_serial$ make
/usr/bin/c++ -o cv_heat2D cv_heat2D.o -O3 -DNDEBUG -std=c++14  -I/home/wdugan/Git/sundials/install/include -I. -L/home/wdugan/Git/sundials/install/lib -lsundials_cvode -lsundials_nvecserial -lm -Wl,-rpath,/home/wdugan/Git/sundials/install/lib
/usr/bin/ld: cv_heat2D.o: in function `PSolve(double, _generic_N_Vector*, _generic_N_Vector*, _generic_N_Vector*, _generic_N_Vector*, double, double, int, void*)':
cv_heat2D.cpp:(.text+0x13): undefined reference to `N_VProd'
/usr/bin/ld: cv_heat2D.o: in function `PSetup(double, _generic_N_Vector*, _generic_N_Vector*, int, int*, double, void*)':
cv_heat2D.cpp:(.text+0x4b6): undefined reference to `N_VGetArrayPointer'
/usr/bin/ld: cv_heat2D.cpp:(.text+0x57e): undefined reference to `N_VConst'
/usr/bin/ld: cv_heat2D.o: in function `Solution(double, _generic_N_Vector*, UserData&)':
cv_heat2D.cpp:(.text+0x624): undefined reference to `N_VGetArrayPointer'

...

collect2: error: ld returned 1 exit status
make: *** [Makefile:85: examples] Error 1

Environment:

  • SUNDIALS v7.0.0
  • Ubuntu 24.04 LTS
  • GCC 13.2.0

Edit - Test outputs

As the documentation suggests, i have run 'make test' and 'make test_install'. All is success.
test_output.txt

@willidu
Copy link
Author

willidu commented Dec 2, 2024

The problem has been identified. The Makefile generated for the examples during the SUNDIALS build does not account for which third-party libraries are enabled etc. The file includes

all: examples examples_bl examples_klu examples_slumt

Since LAPACK was disabled when building SUNDIALS the examples_bl should not be built. This also explains why running CMake to regenereate the Makefile fixes the issue.

Suggested fix

Update the docs to make this more clear (coming from a non-native English speaker).

@balos1
Copy link
Member

balos1 commented Dec 2, 2024

Thanks @willidu. We will try and make the documentation more clear about when re-running CMake is necessary.

@balos1 balos1 changed the title [BUG] Error building examples on Linux Error building examples on Linux Dec 2, 2024
@Steven-Roberts
Copy link
Collaborator

I noticed when running

cd install/examples/cvode/CXX_serial
make VERBOSE=1

some linking flags appear to be missing for cv_heat2D.cpp and cv_kpr.cpp:

/usr/bin/c++ -O3 -DNDEBUG -O3 -DNDEBUG -std=c++14 -I/home/roberts115/Documents/SUNDIALS/SUNDIALS/main/install/include -I. -c cv_heat2D.cpp                                                                           
/usr/bin/c++ -O3 -DNDEBUG -O3 -DNDEBUG -std=c++14 -I/home/roberts115/Documents/SUNDIALS/SUNDIALS/main/install/include -I. -c cv_kpr.cpp                                                                              
/usr/bin/c++ -o cv_heat2D cv_heat2D.o -O3 -DNDEBUG -std=c++14  -I/home/roberts115/Documents/SUNDIALS/SUNDIALS/main/install/include -I. -L/home/roberts115/Documents/SUNDIALS/SUNDIALS/main/install/lib64 -lsundials_c
vode -lsundials_nvecserial -lm -Wl,-rpath,/home/roberts115/Documents/SUNDIALS/SUNDIALS/main/install/lib64

@balos1
Copy link
Member

balos1 commented Dec 2, 2024

@Steven-Roberts I think core is missing from here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants