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

Compile with sundials>=6 #617

Open
jschueller opened this issue Nov 4, 2023 · 2 comments
Open

Compile with sundials>=6 #617

jschueller opened this issue Nov 4, 2023 · 2 comments

Comments

@jschueller
Copy link

jschueller commented Nov 4, 2023

FMPy does not build with sundials 6.x, here is a small patch to add the necessary context argument when calling sundials functions:
0001-Compile-with-sundials-6.patch.txt
this is necessary to get the full build on conda-forge: https://github.com/conda-forge/fmpy-feedstock/blob/main/recipe/meta.yaml#L46
cc @t-sommer

@t-sommer
Copy link
Contributor

t-sommer commented Nov 6, 2023

FMPy does not build with sundials 6.x

Can provide steps to reproduce the problem?

@jschueller
Copy link
Author

jschueller commented Nov 6, 2023

yes, building from the docker file:

FROM condaforge/miniforge3
MAINTAINER jsr
RUN conda install -y sundials attrs numpy cmake make
RUN conda install -y compilers
WORKDIR /tmp
RUN git clone --depth 1 --recursive https://github.com/CATIA-Systems/FMPy.git
ENV CFLAGS="-I/opt/conda/include/"
RUN cd FMPy && python build_binaries.py

it errors with:

CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is GNU 12.3.0
-- The CXX compiler identification is GNU 12.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/conda/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/conda/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.8s)
-- Generating done (0.0s)
-- Build files have been written to: /tmp/FMPy/src/linux64
[  4%] Building C object CMakeFiles/logging.dir/logging/logging.c.o
[  8%] Linking C shared library logging.so
[  8%] Built target logging
[ 12%] Building C object CMakeFiles/FMUContainer.dir/tmp/FMPy/thirdparty/Reference-FMUs/src/FMI.c.o
[ 16%] Building C object CMakeFiles/FMUContainer.dir/tmp/FMPy/thirdparty/Reference-FMUs/src/FMI2.c.o
[ 20%] Building C object CMakeFiles/FMUContainer.dir/tmp/FMPy/thirdparty/mpack/src/mpack/mpack-common.c.o
[ 25%] Building C object CMakeFiles/FMUContainer.dir/tmp/FMPy/thirdparty/mpack/src/mpack/mpack-expect.c.o
[ 29%] Building C object CMakeFiles/FMUContainer.dir/tmp/FMPy/thirdparty/mpack/src/mpack/mpack-node.c.o
[ 33%] Building C object CMakeFiles/FMUContainer.dir/tmp/FMPy/thirdparty/mpack/src/mpack/mpack-platform.c.o
[ 37%] Building C object CMakeFiles/FMUContainer.dir/tmp/FMPy/thirdparty/mpack/src/mpack/mpack-reader.c.o
[ 41%] Building C object CMakeFiles/FMUContainer.dir/tmp/FMPy/thirdparty/mpack/src/mpack/mpack-writer.c.o
[ 45%] Building C object CMakeFiles/FMUContainer.dir/fmucontainer/FMUContainer.c.o
[ 50%] Building C object CMakeFiles/FMUContainer.dir/fmucontainer/fmi2Functions.c.o
[ 54%] Building C object CMakeFiles/FMUContainer.dir/fmucontainer/fmi3Functions.c.o
[ 58%] Linking C shared library FMUContainer.so
[ 58%] Built target FMUContainer
[ 62%] Building C object CMakeFiles/cswrapper.dir/cswrapper/cswrapper.c.o
/tmp/FMPy/src/cswrapper/cswrapper.c: In function 'fmi2Instantiate':
/tmp/FMPy/src/cswrapper/cswrapper.c:300:16: error: too few arguments to function 'N_VNew_Serial'
  300 |         m->x = N_VNew_Serial(m->nx);
      |                ^~~~~~~~~~~~~
In file included from /tmp/FMPy/src/cswrapper/cswrapper.c:18:
/opt/conda/include/nvector/nvector_serial.h:85:26: note: declared here
   85 | SUNDIALS_EXPORT N_Vector N_VNew_Serial(sunindextype vec_length, SUNContext sunctx);
      |                          ^~~~~~~~~~~~~
/tmp/FMPy/src/cswrapper/cswrapper.c:301:21: error: too few arguments to function 'N_VNew_Serial'
  301 |         m->abstol = N_VNew_Serial(m->nx);
      |                     ^~~~~~~~~~~~~
/opt/conda/include/nvector/nvector_serial.h:85:26: note: declared here
   85 | SUNDIALS_EXPORT N_Vector N_VNew_Serial(sunindextype vec_length, SUNContext sunctx);
      |                          ^~~~~~~~~~~~~
/tmp/FMPy/src/cswrapper/cswrapper.c:305:16: error: too few arguments to function 'SUNDenseMatrix'
  305 |         m->A = SUNDenseMatrix(m->nx, m->nx);
      |                ^~~~~~~~~~~~~~
In file included from /tmp/FMPy/src/cswrapper/cswrapper.c:19:
/opt/conda/include/sunmatrix/sunmatrix_dense.h:79:27: note: declared here
   79 | SUNDIALS_EXPORT SUNMatrix SUNDenseMatrix(sunindextype M, sunindextype N, SUNContext sunctx);
      |                           ^~~~~~~~~~~~~~
/tmp/FMPy/src/cswrapper/cswrapper.c:307:16: error: too few arguments to function 'N_VNew_Serial'
  307 |         m->x = N_VNew_Serial(1);
      |                ^~~~~~~~~~~~~
/opt/conda/include/nvector/nvector_serial.h:85:26: note: declared here
   85 | SUNDIALS_EXPORT N_Vector N_VNew_Serial(sunindextype vec_length, SUNContext sunctx);
      |                          ^~~~~~~~~~~~~
/tmp/FMPy/src/cswrapper/cswrapper.c:308:21: error: too few arguments to function 'N_VNew_Serial'
  308 |         m->abstol = N_VNew_Serial(1);
      |                     ^~~~~~~~~~~~~
/opt/conda/include/nvector/nvector_serial.h:85:26: note: declared here
   85 | SUNDIALS_EXPORT N_Vector N_VNew_Serial(sunindextype vec_length, SUNContext sunctx);
      |                          ^~~~~~~~~~~~~
/tmp/FMPy/src/cswrapper/cswrapper.c:310:16: error: too few arguments to function 'SUNDenseMatrix'
  310 |         m->A = SUNDenseMatrix(1, 1);
      |                ^~~~~~~~~~~~~~
/opt/conda/include/sunmatrix/sunmatrix_dense.h:79:27: note: declared here
   79 | SUNDIALS_EXPORT SUNMatrix SUNDenseMatrix(sunindextype M, sunindextype N, SUNContext sunctx);
      |                           ^~~~~~~~~~~~~~
/tmp/FMPy/src/cswrapper/cswrapper.c:313:20: error: too few arguments to function 'CVodeCreate'
  313 |     m->cvode_mem = CVodeCreate(CV_BDF);
      |                    ^~~~~~~~~~~
In file included from /tmp/FMPy/src/cswrapper/cswrapper.c:17:
/opt/conda/include/cvode/cvode.h:113:23: note: declared here
  113 | SUNDIALS_EXPORT void *CVodeCreate(int lmm, SUNContext sunctx);
      |                       ^~~~~~~~~~~
/tmp/FMPy/src/cswrapper/cswrapper.c:328:13: error: too few arguments to function 'SUNLinSol_Dense'
  328 |     m->LS = SUNLinSol_Dense(m->x, m->A);
      |             ^~~~~~~~~~~~~~~
In file included from /tmp/FMPy/src/cswrapper/cswrapper.c:20:
/opt/conda/include/sunlinsol/sunlinsol_dense.h:58:33: note: declared here
   58 | SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_Dense(N_Vector y, SUNMatrix A, SUNContext sunctx);
      |                                 ^~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/cswrapper.dir/build.make:76: CMakeFiles/cswrapper.dir/cswrapper/cswrapper.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:141: CMakeFiles/cswrapper.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Failed to add logger proxy function. /tmp/FMPy/fmpy/logging/linux64/logging.so: cannot open shared object file: No such file or directory
Failed to add logger proxy function. /tmp/FMPy/fmpy/logging/linux64/logging.so: cannot open shared object file: No such file or directory
Traceback (most recent call last):
  File "/tmp/FMPy/build_binaries.py", line 37, in <module>
    check_call(['cmake', '--build', build_dir, '--config', configuration])
  File "/opt/conda/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', 'src/linux64', '--config', 'Release']' returned non-zero exit status 2.
The command '/bin/sh -c cd FMPy && python build_binaries.py' returned a non-zero code: 1

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

No branches or pull requests

2 participants