AMICI-dev / AMICI

Advanced Multilanguage Interface to CVODES and IDAS
https://amici.readthedocs.io/
Other
107 stars 30 forks source link

'reduce' is not a member of 'std' std::reduce(idlist.begin(), idlist.end()) #2463

Closed derleanfv closed 6 days ago

derleanfv commented 2 weeks ago

What did you expect to happen? After installing AMICI and making sure to run mex -setup C++, I used the model examples in \models. For example rebuild_model_robertson. I expect it would just compile.

What has happened instead? There was an error in using "std::reduce(idlist.begin(), idlist.end())" in the file \include/amici/model_dae.h:62:13. I checked the version of C++, but in the command line before outputting the error it says mex COPTIMFLAGS=' -DNDEBUG' CXXFLAGS='$CXXFLAGS -std=c++17' -c -outdir "C:\Users...", which includes c++17, which should support std::reduce.

To Reproduce Compile an example by running rebuild_model_robertson Steps to reproduce the behavior Ideally include minimal code examples here

AMICI version and system environment

How to fix Do you know how to resolve the problem? No, I have been trying for hours to find a solution. I am not experienced with c++. Can you submit a pull request?

Thank you for the help

dweindl commented 2 weeks ago

Hi @derleanfv, the matlab-mingw compiler seems to be too old too support C++17.

I don't have any Windows machine available to test this, but can you try:

  1. Download a recent mingw version from https://www.mingw-w64.org/downloads/
  2. Configure matlab as described here
  3. retry what you did before (ignoring any warnings that this version of mingw is not compatible with that matlab release)
derleanfv commented 6 days ago

Hi,

thank you for the help. I managed to get it working by:

  1. Installing matlab 2017b
  2. Installing the mingw64 compiler here https://www.msys2.org/, I followed this instruction https://stackoverflow.com/questions/30069830/how-can-i-install-mingw-w64-and-msys2
  3. then opening the file you described in step 2 and leading it to the path C:\msys64\mingw64

Then when executing an amici script, matlab threw out a warning, but it worked. I was shocked, that the "MATLAB Support for MinGW-w64 C/C++/Fortran Compiler" even for 2024a is too outdated to compile. But since I can create the simulate files with matlab 2017b, I can also call them with matlab 2024a and everything works fine.

Thank you