且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 C/C++ 程序中嵌入 GNU Octave?

更新时间:2023-01-28 11:22:39

像这样的

embed.cpp

#include <iostream>
#include <octave/octave.h>

int main(int argc,char* argv)
{
  int embedded;
  octave_main(argc,argv,embedded=0);  
  return embedded;
}

然后

mkoctfile embed.cpp --link-stand-alone -o embed 以制作独立的可执行文件.

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

要调用 octave 函数,无论它们是由脚本还是 octaveforge 模块提供的,您都可以使用 feval,它将 octave 函数名称作为字符串、该函数的输入变量的 octave_value_list 以及该函数的变量数作为整数.

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.

请参阅此处了解更多信息.