How to embed the GNU Octave in C/C++ program?(如何在 C/C++ 程序中嵌入 GNU Octave?)
问题描述
我想使用 GNU Octave 库计算一些矩阵算法.我知道我可以使用 Octave 的 C/C++ API 进行基本使用.但是我想使用的方法不在 Octave 的默认包中.那么如何在C/C++程序中使用Octave的控制包呢?
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 default packages of Octave. So how to use Octave's control package in the C/C++ program?
推荐答案
像这样的
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.
请参阅此处了解更多信息.
这篇关于如何在 C/C++ 程序中嵌入 GNU Octave?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 C/C++ 程序中嵌入 GNU Octave?


基础教程推荐
- CString 到 char* 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05