Using liboctave in matlab

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Using liboctave in matlab

Frederic Gobry

Hello,

I'm looking for   a conveniant way  to   use C++ code   in both Octave
 and Matlab. In fact, I want to  write some code  that can be compiled
into a .oct and a .mex without (or with few) modifications.

My first idea was  to write code as if  it were for octave (using  the
Matrix classes  in  liboctave) and to  add  a wrapper for  matlab that
converts its input  and output into  octave's matrices.  Here come the
problems :   I can compile my  code,  I can  load it  dynamically into
matlab,  and it seems  to work quite  well, except  that I encounter a
"Segmentation violation" when I try to  clean the .mex from the memory
(with a 'clear function' or when I  exit).  In fact, I've noticed that
simply linking  a normal mexfile with  liboctave,libcruft,..., without
even using a function it provides, is enough to cause this behavior.

Does anybody  know what's happening, or  maybe if there is another way
to use the same code with both programs ??

Thank you in advance !

Fred

PS :

I use :

- Octave 2.0.9  on   Solaris 2.5.1,  compiled with shared   libraries,
dynamic linking and lite kernel.

- My version of Matlab is 4.2c

- gcc 2.7.2.2

- fortran compiler f77 3.0.1 (sun compiler)


--
    Frederic GOBRY               IDIAP
                            Rue du Simplon 4,
[hidden email]     CH 1920 - Martigny
Tel: +41 27 721 77 31       Switzerland


Reply | Threaded
Open this post in threaded view
|

Re: Using liboctave in matlab

Frederic Gobry
I answer to my own question :

> matlab,  and it seems  to work quite  well, except  that I encounter a
> "Segmentation violation" when I try to  clean the .mex from the memory
> (with a 'clear function' or when I  exit).  In fact, I've noticed that
> simply linking  a normal mexfile with  liboctave,libcruft,..., without
> even using a function it provides, is enough to cause this behavior.

This happens when I link against the dynamic libraries, not the static
ones. In fact it has no relationship  with Octave in itself... It must
come  from the   way Matlab handles    dynamic binding,  but  I  don't
understand these mechanisms enough to go further in my explanations...

Frederic