Octave-C++-API and Boost Unit Tests result in Segmentation Fault

123 views Asked by At

I try to unit test my C++ code where I use the octave-C++-API. If I use anything from octave in the boost unit test I get the error:

Segmentation fault (core dumped)

The compilation works just fine and if use both octave and boost separately it works fine. Does anyone know what I did wrong?

Here is my minimal example:

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE boostOctaveTest
#include <boost/test/unit_test.hpp>
#include <octave/oct.h>

BOOST_AUTO_TEST_SUITE(TestOctave)

BOOST_AUTO_TEST_CASE(octave)
{
  octave_value var = 42;
  BOOST_CHECK(var.int_value() == 42ul);
}

BOOST_AUTO_TEST_SUITE_END()

The compile command is:

mkoctfile --link-stand-alone -D_GLIBCXX_ASSERTIONS main.cpp -o main -I/home/jlammering/tools/Boost/boost_1_72_0 -L"/home/jlammering/tools/Boost/boost_1_72_0/stage/lib" -l"boost_unit_test_framework"

My software:

  • OS: CentOS 8
  • Boost: version 1_72
  • Octave: version 5.2
1

There are 1 answers

0
jlammering On BEST ANSWER

The solution was to switch to different software versions. With this setup it works:

  • OS: ubuntu 2204
  • Boost: version 1_74
  • Octave: version 6.4