help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to call Octave/Matlab script from C++ in Ubuntu?


From: Kai Torben Ohlhus
Subject: Re: How to call Octave/Matlab script from C++ in Ubuntu?
Date: Thu, 10 Apr 2014 08:36:47 +0200

On Thu, Apr 10, 2014 at 4:36 AM, kaatish <address@hidden> wrote:
Hi,
I have a bunch of related Octave/Matlab files out of which one of them
contains a function that I need to call and use that result in a C++ program
that I am writing on Ubuntu. I have Octave installed on this system so I'll
be using Octave specific solutions to this problem.

I have installed the octave header file packages. I seem to get an error
when writing this simple code.

    int main(int argc, const char *argv[])
    {
      octave_main(argc, (char**)argv, true);
      ColumnVector sz(2);
      sz(0) = 10;
      sz(1) = 12;
      octave_value_list functionArguments = octave_value(sz);
      do_octave_atexit();
      return 0;
    }

The compilation command is

    g++ -L /usr/lib/octave/3.2.4 -I /usr/lib/octave-3.2.4 -loctinterp
-loctave -loctave salone.cpp

The error that I get is

    /usr/bin/ld: /usr/lib/octave-3.2.4/liboctinterp.so: undefined reference
to symbol 'Array<std::basic_string&lt;char, std::char_traits&lt;char>,
std::allocator<char> > >::~Array()'
    /usr/bin/ld: note: 'Array<std::basic_string&lt;char,
std::char_traits&lt;char>, std::allocator<char> > >::~Array()' 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

Could someone please explain how to solve this? I have seen some example but
they are about making a standalone problem, which does not seem to be what I
am looking for. I just have a complicated Octave script which I want to use
with a C++ program.

So, apart from solving this error, how do I do that? I could not find any
documentation which was clear enough to help me do so.

Thanks.



--
View this message in context: http://octave.1599824.n4.nabble.com/How-to-call-Octave-Matlab-script-from-C-in-Ubuntu-tp4663554.html
Sent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave

Hello,

You seem to have an older Octave version. Instead of g++ you should compile your standalone-program with mkoctfile like described in [1]. Under Ubuntu it is available in the package liboctave-dev [2].

HTH, Kai

[1] https://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-Programs
[2] http://packages.ubuntu.com/quantal/liboctave-dev

reply via email to

[Prev in Thread] Current Thread [Next in Thread]