[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unable to load user defined function through feval - crashing
From: |
Arun |
Subject: |
Unable to load user defined function through feval - crashing |
Date: |
Tue, 12 Mar 2019 10:45:27 -0500 (CDT) |
Hi,
i am facing issue while loading my own octave function through cpp
standalone application .
my own octave is working well in octave cli and octave editor in octave
4.2.2 , where as in cpp its throwing segment fault , whereas inbuilt
function like gcd its working if running example
my cpp function which is failing
#include <iostream>
#include <iostream>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/interpreter.h>
using namespace std;
int
main (void)
{
try{
string_vector argv (2);
argv(0) = "embedded";
argv(1) = "-q";
octave_main (2, argv.c_str_vec (), 1);
octave_idx_type n = 1;
octave_value_list in;
in(0) = "test";
octave_value_list out = feval ("audioclick", in, 1);
if (out.length () > 0)
std::cout << out(0).int_value ()
<< std::endl;
else
std::cout << "invalid\n";
}catch(const std::exception& e){
std::cout << " a standard exception was caught, with message '"
<< e.what() << "'\n";
}
}
i saved audioclick path in octaverc
i used mkoctfile --link-stand-alone main.cpp -o embedded for compilation
the following example program working successfully
example program
#include <iostream>
#include <iostream>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/interpreter.h>
using namespace std;
int
main (void)
{
try{
string_vector argv (2);
argv(0) = "embedded";
argv(1) = "-q";
octave_main (2, argv.c_str_vec (), 1);
octave_idx_type n = 1;
octave_value_list in;
for (octave_idx_type i = 0; i < n; i++)
in(i) = octave_value (5 * (i + 2));
octave_value_list out = feval ("gcd", in, 1);
if (out.length () > 0)
std::cout << "GCD of ["
<< in(0).int_value ()
<< ", "
<< in(1).int_value ()
<< "] is " << out(0).int_value ()
<< std::endl;
else
std::cout << "invalid\n";
}catch(const std::exception& e){
std::cout << " a standard exception was caught, with message '"
<< e.what() << "'\n";
}
}
please help me to resolve this issue as i am struggling
--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
- Unable to load user defined function through feval - crashing,
Arun <=