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?
Asked
Active
Viewed 2.5k times
1 Answers
22
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.

Blazor
- 171
- 4
- 11

Appleman1234
- 15,946
- 45
- 67
-
7Food for thought for anyone who lands here: using embed octave means you must release your code under a GPL like license http://wiki.octave.org/FAQ#If_I_write_code_using_Octave_do_I_have_to_release_it_under_the_GPL.3F – waiting4op2deliver Nov 19 '16 at 06:36