help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling Octave from C++


From: Tatsuro MATSUOKA
Subject: Re: Calling Octave from C++
Date: Tue, 27 Mar 2018 09:16:41 +0900 (JST)

----- Original Message -----

> From: Tatsuro MATSUOKA 
> To: andrea.delbravo"help-octave
> Cc: 
> Date: 2018/3/26, Mon 03:05
> Subject: Re: Calling Octave from C++
> ----- Original Message -----
>>  From: andrea.delbravo
>>  To: help-octave
>>  Cc: 
>>  Date: 2018/3/23, Fri 19:28
>>  Subject: Re: Calling Octave from C++
>> 
>>  Well, sorry for the nmissing infos.
>>  I wirk with Fedora 26 Ocatve 4.2.1. I tried also with Fedora 27 Octave 
> 4.2.2
>>  but the problem persist.
>>  The application run perfectly under fedora 25 Octave 4.0.3.
>>  I minimize the application in order to focalize the problem:
>>  After several initialization the core of the problem is:
>> 
>>  // THIS CODE IS WORKING
>>  int qq =10;
>>  int rr =15;
>>  in(0) = octave_value(qq);
>>  in(1) = octave_value(rr);
>>  octave_value_list out = feval ("gcd", in, 1);
>>  std::cout << out(0).int_value ()
>>  and it prints the correct result = 5 the Greatest common disisor between 10
>>  and 15
> 
> I have tested the above code on octave 4.2.2 for windows.
> The program ended with segmentation fault.
> Something might be wrong with standalone program on octave-4.2.2.
> I will build windows binary current stable (to octave 4.4 in near future)
> and test it and see platform dependence.
> Tatsuro
> 
>>  but if I run
>>  // THIS CODE IN NOT WORKING
>>  octave_value_list out = feval ("pp", in, 1);
>>  where pp.m is a stupid Octave script which shuld disply the two numbers
>>  (tested and working in the Octave environment)
>> 
>>  Application crashes with Segmentation Fault insiede the interpreter, and I
>>  cannot debug it inside because the interpreter is not compiled with debug
>>  information
>> 
>>  The OCTAVE_PATH environment variable define the path where the .m files are
>>  saved (see Octave manual for example version 4.4. March 2018 pag 17, but
>>  valid since a long time in all the Octave Version. I've been using it 
> for at
>>  least 7 years
>> 
>>  The OCTAVE_PATH variable is correctly seen inside the C++ cose. Ifact if I
>>  run the program with:
>> 
>>  // THIS CODE IS WORKING
>>  in(0) = octave_value(a); // where a is a char[] = OCTAVE_PATH
>>  octave_value_list out = feval ("getenv", in, 1);   //getenv 
> return the
>>  Evironmental Variable (see Octave manual)
>>  std::cout << out(0).string_value ()   // print the correct 
> OCTAVE_PATH 
>>  value
>> 
>>  It seems that is I use an embedded function i worke, but if I use  my own
>>  script it crashes
>> 
>>  Thanks a lot in advance


After fixing the my fault of LD_LIBRARY_PATH
(see https://savannah.gnu.org/bugs/?53446#comment5)

#include <iostream>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/interpreter.h>

int
main (void)
{
  octave_value_list in;
  // THIS CODE IS WORKING
  int qq =10;
  int rr =15;
  in(0) = octave_value(qq);
  in(1) = octave_value(rr);
  octave_value_list out = feval ("gcd", in, 1);
  std::cout << out(0).int_value ();
  clean_up_and_exit(0);
}

Still hang for me on current stable source (HG-ID 231847364696 upcoming 4.4).

gdb results are:

Thread 1 "test_01" received signal SIGABRT, Aborted.
0x00007ffff4ef0428 in __GI_raise (address@hidden)
    at ../sysdeps/unix/sysv/linux/raise.c:54
54    ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff4ef0428 in __GI_raise (address@hidden)
    at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff4ef202a in __GI_abort () at abort.c:89
#2  0x00007ffff76f7dc7 in octave::__get_interpreter__ (who="feval")
    at libinterp/corefcn/interpreter-private.cc:49
#3  0x00007ffff76f7e59 in octave::__get_symbol_table__ (who="feval")
    at libinterp/corefcn/interpreter-private.cc:86
#4  0x00007ffff73951a1 in octave::feval (name="gcd", args=..., 
    address@hidden) at libinterp/parse-tree/oct-parse.yy:5197
#5  0x000000000040338e in feval (nargout=1, args=..., name="gcd")
    at /opt/octave-stable/include/octave-4.3.0+/octave/../octave/parse.h:647

Tatsuro
#6  main () at test_01.cc:16



reply via email to

[Prev in Thread] Current Thread [Next in Thread]