How to embed GNU Octave in a C / C ++ program?

I want to calculate some matrix algorithms using the GNU Octave library. I know that I can use the C / C ++ API for Octave for basic use. However, the method I want to use is not part of the default Octave packages. So, how to use the Octave management pack in a C / C ++ program?

+8
c ++ c package controls octave
source share
2 answers

Something like that

embed.cpp

#include <iostream> #include <octave/octave.h> int main(int argc,char* argv) {   int embedded;   octave_main(argc,argv,embedded=0);    return embedded; } 

Then

mkoctfile embed.cpp --link-stand-alone -o embed to make a standalone executable.

To call octave functions, regardless of whether they are provided by scripts or octave modules, you can use feval, which takes the name of the octave function as a string, octave_value_list of input variables for this function, and the number of variables for this function as an integer.

See here for more details.

+13
source share

I found this link useful: How to use Octave functions in C / C ++

0
source share

All Articles