Octave is a very nice free Matlab clone and provides many helpful mathematical functions. Especially linear algebra calculations are rather easy, but Octave comes also with lot more. For more information and to download octave see the homepage of the project at www.gnu.org/software/octave/. To use the very powerful Octave functions in your C/C++ programs include the main octave header file
which is mostly located in
Mostly, it will not be necessary to include further header files, since this file already includes most of the octave functions.
Nevertheless we will refer to the respective special headers in the following to give you the chance to gain some further information.
To compile your C/C++ code, e.g. with g++, set the
-I option of your compiler to the location of the octave include files.
For the linking process octave provides you with a very useful make file
Standardly this make file is also used for translating octave code into .oct files.
It comes with the option
--link-stand-alone which produces an executable file of your C/C++ program containing octave subroutines.
The following Makefile represents a simple example to compile and link your program called
test at the end:
Please note that the spaces before the commands must be a tabulator character according to standard rules of Makefiles.
The environment variable
$OCTAVE_INCLUDE should be set to your octave include path, which could be, e.g.,
By using the command
make all your program will be compiled and linked.