Hi Sébastien,

Am 30.11.2025 um 22:02 schrieb Sébastien Villemot:
Hi Markus,

Le mercredi 12 novembre 2025 à 10:55 +0100, Markus Muetzel a écrit :
Am 10.11.2025 um 14:13 schrieb Sébastien Villemot:
Le lundi 10 novembre 2025 à 12:22 +0100, BERENGUIER Baptiste a écrit :
I am using debian trixie with the official package for octave. I try to port a matlab code using ode15s and encounter this error: error: __ode15__: support for sundials_ida, sundials_nvecserial was unavailable or disabled when Octave was built error: called from     ode15s at line 324 column 22 Should I do a bug report?
  This is a known issue, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1082580
   Unfortunately there is no fix yet. And it is unlikely it will ever be fixed 
in trixie.
I posted a potential fix/workaround on Octave's discourse forum: Improving MPI detection - maintainers - GNU Octave Could that patch be used to enable these functions in Debian Trixie?
  You'd need to regenerate the configure script after applying that change. Something 
like "autoreconf -fi" should do that.
Thanks for suggesting this workaround, and sorry for my late reply.

I’ve tried to rebuild the octave in Debian unstable, using your
proposed patch.

Sundials is correctly detected at the configure step, but then I get
the following compilation error:

libtool: compile:  g++ -DHAVE_CONFIG_H -I. -Iliboctave -I./liboctave 
-I./liboctave/array -Iliboctave/numeric -I./liboctave/numeric 
-Iliboctave/operators -I./liboctave/operators -I./liboctave/system 
-I./liboctave/util -I./libinterp/octave-value -Ilibinterp -I./libinterp 
-I./libinterp/operators -Ilibinterp/parse-tree -I./libinterp/parse-tree 
-Ilibinterp/corefcn -I./libinterp/corefcn -I./liboctave/wrappers 
-I/usr/include/hdf5/serial -I/usr/include/GraphicsMagick 
-I./libinterp/dldfcn/replace-mpi -I/usr/include/suitesparse -Wdate-time 
-D_FORTIFY_SOURCE=2 -fPIC -pthread -fopenmp -Wall -W -Wshadow 
-Woverloaded-virtual -Wold-style-cast -Wformat -Wpointer-arith -Wwrite-strings 
-Wcast-align -Wcast-qual -g -O2 
-ffile-prefix-map=/home/sebastien/debian/octave=. -flto=auto -ffat-lto-objects 
-fstack-protector-strong -fstack-clash-protection -Wformat 
-Werror=format-security -fcf-protection -c libinterp/dldfcn/__ode15__.cc  -fPIC 
-DPIC -o libinterp/dldfcn/.libs/__ode15___la-__ode15__.o
In file included from /usr/include/sundials/priv/sundials_context_impl.h:25,
                  from /usr/include/sundials/sundials_context.h:22,
                  from /usr/include/sundials/sundials_nvector.h:51,
                  from /usr/include/nvector/nvector_serial.h:42,
                  from libinterp/dldfcn/__ode15__.cc:50:
libinterp/dldfcn/__ode15__.cc: In member function 'void 
octave::IDA::initialize()':
libinterp/dldfcn/__ode15__.cc:593:26: error: 'MPI_COMM_NULL' was not declared 
in this scope; did you mean 'SUN_COMM_NULL'?
   593 |   if (SUNContext_Create (SUN_COMM_NULL, &m_sunContext) < 0)
       |                          ^~~~~~~~~~~~~


Thank you for testing the patch. Sorry, it didn't work.

For some reason, that wasn't an issue when I tested in Ubuntu 25.10. Maybe, they have a different version of SUNDIALS? Or something else is different on my test system.

Does the attached updated version of the patch work for you? With that patch, I'm still able to build Octave using the SUNDIALS 7.1.1+dsfg1-10 packages from Ubuntu 25.10.

Best,

Markus
# HG changeset patch
# User Markus Mützel <[email protected]>
# Date 1762890283 -3600
#      Tue Nov 11 20:44:43 2025 +0100
# Node ID c92b53bfc1082d8c49b6edddaeed093bb49a519c
# Parent  8364bb87255e0e3718b9e64e1337fdd01ed1e995
build: Fix building with SUNDIALS 7 built with MPI.

* configure.ac (sundials_nvecserial): Try check for headers and library with
replaced "mpi.h".
* libinterp/dldfcn/: Add replacement for "mpi.h".
* libinterp/dldfcn/config-module.awk: Add new file to build system.

See also: https://octave.discourse.group/t/6484

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -2379,10 +2379,28 @@ fi
 
 ### Check for SUNDIALS NVECTOR serial library and header.
 
-OCTAVE_CHECK_LIB(sundials_nvecserial, [SUNDIALS NVECTOR],
+OCTAVE_CHECK_LIB(sundials_nvecserial, [SUNDIALS NVECTOR], [],
+  [nvector/nvector_serial.h], [N_VNew_Serial],
+  [C++], [don't use SUNDIALS NVECTOR library, disable solvers ode15i and 
ode15s])
+
+if test -z "$SUNDIALS_NVECSERIAL_LIBS"; then
+  ## Invalidate the cache and try again with "mpi.h" replacement.
+  ## This might be required if SUNDIALS 7 or newer was built with MPI.
+  $as_unset ac_cv_header_nvector_nvector_serial_h
+  $as_unset ac_cv_lib_sundials_nvecserial_N_VNew_Serial
+  $as_unset octave_cv_lib_sundials_nvecserial
+  save_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="-I${srcdir}/libinterp/dldfcn/replace-mpi $CPPFLAGS"
+  OCTAVE_CHECK_LIB(sundials_nvecserial, [SUNDIALS NVECTOR],
   [SUNDIALS NVECTOR serial library not found.  The solvers ode15i and ode15s 
will be disabled.],
   [nvector/nvector_serial.h], [N_VNew_Serial],
   [C++], [don't use SUNDIALS NVECTOR library, disable solvers ode15i and 
ode15s])
+  CPPFLAGS="$save_CPPFLAGS"
+
+  if test "x$octave_cv_lib_sundials_nvecserial" == xyes; then
+    SUNDIALS_NVECSERIAL_CPPFLAGS="$SUNDIALS_NVECSERIAL_CPPFLAGS 
-I${srcdir}/libinterp/dldfcn/replace-mpi"
+  fi
+fi
 
 ### Check for SUNDIALS IDA library and header.
 
diff --git a/libinterp/dldfcn/config-module.awk 
b/libinterp/dldfcn/config-module.awk
--- a/libinterp/dldfcn/config-module.awk
+++ b/libinterp/dldfcn/config-module.awk
@@ -35,6 +35,9 @@ BEGIN {
   print "  %reldir%/module-files \\"
   print "  %reldir%/oct-qhull.h"
   print ""
+  print "noinst_HEADERS += \\"
+  print "  %reldir%/replace-mpi/mpi.h"
+  print ""
 }
 /^#.*/ { next; }
 {
diff --git a/libinterp/dldfcn/replace-mpi/mpi.h 
b/libinterp/dldfcn/replace-mpi/mpi.h
new file mode 100644
--- /dev/null
+++ b/libinterp/dldfcn/replace-mpi/mpi.h
@@ -0,0 +1,39 @@
+////////////////////////////////////////////////////////////////////////
+//
+// Copyright (C) 2025 The Octave Project Developers
+//
+// See the file COPYRIGHT.md in the top-level directory of this
+// distribution or <https://octave.org/copyright/>.
+//
+// This file is part of Octave.
+//
+// Octave is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Octave is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Octave; see the file COPYING.  If not, see
+// <https://www.gnu.org/licenses/>.
+//
+////////////////////////////////////////////////////////////////////////
+
+// This file is only used if SUNDIALS version 7 or newer was built with MPI.
+// In that case, their headers include "mpi.h". We do not need any MPI
+// functions.  But their headers use the type "MPI_Comm" and "MPI_COMM_NULL"
+// if SUNDIALS was built with MPI.
+// Add a bogus definition here.
+// Do not install this file or use in any other projects.
+
+#if ! defined (octave_replace_mpi_h)
+#define octave_replace_mpi_h 1
+
+#define MPI_COMM_NULL 0
+typedef int MPI_Comm;
+
+#endif

Reply via email to