Hi, 
I am new to octave c++ api, I am using one of the example code embedded.cc
to build a standalone C++ application. The standalone application make use
of the shared libraries liboctave.so, liboctinterp.so,
libcurst.so, These libraries were build using the octave source code. 
I didnt have any problem with the octave build. 

I was able to build standalone application without any problem. I face
problem when running my standalone application. The source code of my
application is given below.
#include <iostream>
#include <iostream>
#include <oct.h>
#include <octave.h>
#include <parse.h>
int main(void) {
  string_vector argv (2);
  argv(0) = "embedded";
  argv(1) = "-q";

  octave_main (2, argv.c_str_vec(), 1);

  octave_idx_type n = 2;
  Matrix a_matrix = Matrix (1, 2);

  std::cout << "GCD of [";
  for (octave_idx_type i = 0; i < n; i++)
    {
      a_matrix (i) = 5 * (i + 1);
      if (i != 0)
        std::cout << ", " << 5 * (i + 2);
      else
        std::cout << 5 * (i + 2);
    }
  std::cout << "] is ";

  octave_value_list in = octave_value (a_matrix);
  octave_value_list out = feval ("gcd", in, 1);

  if (!error_state && out.length () > 0)
    {
      a_matrix = out(0).matrix_value ();
      if (a_matrix.numel () == 1)
        std::cout << a_matrix(0) << "\n";
      else
        std::cout << "invalid\n";
    }
  else
    std::cout << "invalid\n";
    std::cout << "Hello, world!" << std::endl;
    return 0;
}

The above source code has a statement 
octave_value_list out = feval ("gcd", in, 1);

when I run my standalone c++ application, I get the following error
GCD of [10, 15] is error: feval: function `unimplemented' not found
invalid
Hello, world!

I can understand that octave_main() is trying to initialize the path, using
which feval can load the function gcd. Inside the octave_main function there
is a call to the function initializepaths() which 
read the path from some variable OCTAVE_DB_PATH, OCTAVE_DB_DIR.

I am not sure how tell octave where to look for the octave functions. 
Please can some one help with this issue.

thanks, 
Johnson Abraham

-- 
View this message in context: 
http://old.nabble.com/Calling-octave-function-using-feval-in-C%2B%2B-standalone-application-tp32491362p32491362.html
Sent from the octave-dev mailing list archive at Nabble.com.


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry&reg; mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry&reg; DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to