I want to execute a MatLab script with Octave. I tried to build the example on the wiki page but I get linker error.
address@hidden:~/tmp/octave$ g++ -L /usr/lib/octave-3.2.4 -loctinterp -lcruft -loctave -ooctavetest OctaveTest.cpp
/usr/bin/ld: /usr/lib/octave-3.2.4/liboctinterp.so: undefined reference to symbol 'MatrixType::~MatrixType()'
/usr/bin/ld: note: 'MatrixType::~MatrixType()' is defined in DSO /usr/lib/octave-3.2.4/liboctave.so so try adding it to the linker command line
/usr/lib/octave-3.2.4/liboctave.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
I have installed the Ubuntu 11.10 Octave packages.
#include <iostream>
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/toplev.h> /* do_octave_atexit */
int main(int argc, char** argv) {
const char * argvv [] = {"" /* name of program, not relevant */, "--silent"};
octave_main (2, (char **) argvv, true /* embedded */);
octave_value_list functionArguments;
functionArguments (0) = 2;
functionArguments (1) = "D. Humble";
Matrix inMatrix (2, 3);
inMatrix (0, 0) = 10;
inMatrix (0, 1) = 9;
inMatrix (0, 2) = 8;
inMatrix (1, 0) = 7;
inMatrix (1, 1) = 6;
functionArguments (2) = inMatrix;
const octave_value_list result = feval ("exampleOctaveFunction", functionArguments, 1);
std::cout << "resultScalar is " << result (0).scalar_value () << std::endl;
std::cout << "resultString is " << result (1).string_value () << std::endl;
std::cout << "resultMatrix is\n" << result (2).matrix_value ();
do_octave_atexit ();
}
Does anybody have an idea why the destructor definition is not found by the linker?