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

前端 未结 1 1093
不思量自难忘°
不思量自难忘° 2020-12-03 06:03

I want to calculate some matrix algorithms using the GNU Octave library. I know I can use C/C++ API of Octave for basic use. However the method I want to use is not in the d

相关标签:
1条回答
  • 2020-12-03 06:21

    Something like this

    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 in order to make a standalone executable.

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

    See here for further information.

    0 讨论(0)
提交回复
热议问题