help-octave
[Top][All Lists]
Advanced

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

Re: passing a matrix to a fortran subroutine


From: lash
Subject: Re: passing a matrix to a fortran subroutine
Date: Wed, 15 Jul 1998 14:50:39 -0500 (CDT)

> 
> ----------
> >From: Michael J Ursiak <address@hidden>
> >To: address@hidden
> >Subject: passing a matrix to a fortran subroutine
> >Date: Wed, Jul 15, 1998, 1:12 PM
> >extern "C"
> >{
> >  int F77_FCN (xstuff, XSTUFF) ( int&,int&,double*,int&);
> >}
> >
> 
> >
> >I get the following error when I try to execute this newvd in octave:
> >
> >octave:2> y = newsvd(h)
> >ld.so.1: octave: fatal: relocation error: symbol not found: __f_open_nv:
> >referenced in /a/kenner/lime/homes/ursiak/octave/newstuff/newsvd.oct
> >Killed
> 
> I haven't seen this particular error, but here's some things I had to do
> to get my .oct files working:
> 
> (1) Make sure gcc was compiled with --enable-shared.
> (2) Run mkoctfile with sources, not object files, e.g.
>     mkoctfile newsvd.cc xstuff.f
>   not
>     f77 -c xstuff.f
>     mkoctfile newsvd.cc xstuff.o
> (3) Make sure your LD_LIBRARY_PATH points to your octave libs.  If you
>     configured octave with --prefix=prefix_dir, then LD_LIBRARY_PATH
>     should include prefix_dir/lib/octave-2.x.x (your version here)
> 
> Hope this helps.
> 
> 

I am having a similar problem with octave 2.0.13 under solaris 2.5.1 (SunOS 
5.5.1)

I wrote a c++ routine to do the inner loop of a routine that calculates
tvar (time variance).  My first problem was that mkoctfile would dump core
if I left it as it was, using g++ to do the linking.  If I changed it to 
use gcc or ld, the .oct file would get generated, but when I tried to use
it (or even do a which tvar_oct) octave would report:

error: ld.so.1: octave: fatal: relocation error: symbol not found: 
_t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b0i0.nilRep:
 referenced in /home/tellabx-5/lash/tdv/tvar_oct.oct: 
/home/tellabx-5/lash/tdv/tvar_oct.oct `FStvar_oct__Fv'


I had assumed that this was due to our tools group not installing gcc correctly
(they have recently gone to egcs). Is there any easy way to check if they
compiled gcc with --enable-shared?  I compiled octave with this compiler and
doing an ldd on it shows:

sunl10% ldd ~/progs/octave/bin/octave
        libm.so.1 =>     /usr/lib/libm.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1
        libsocket.so.1 =>        /usr/lib/libsocket.so.1
        libc.so.1 =>     /usr/lib/libc.so.1
        libnsl.so.1 =>   /usr/lib/libnsl.so.1
        libintl.so.1 =>  /usr/lib/libintl.so.1
        libmp.so.1 =>    /usr/lib/libmp.so.1
        libw.so.1 =>     /usr/lib/libw.so.1

Which makes me believe that it can handle shared libraries.  I do notice that
we don't have a shared version of libstdc++ which is where 

_t12basic_string3ZcZt18string_char_traits1ZcZt24__default_alloc_template2b0i0
 
is defined. (Don't you just love that C++ name mangling!!!).  This symbol
does also appear to be in the octave executable file though.

I also made sure that LD_LIBRARY_PATH included the octave library directory,
and the same problems occur. (Just tried that, thanks for the tip.)

Anyway, if anyone has any thoughts about what might be wrong, I would
appreciate it.  I've attatched the c++ file that I am using below, but
the same problems occure with the example files (hello.cc, etc.)

Bill Lash
address@hidden




=====tvar_oct.cc=========================
#include <octave/oct.h>

DEFUN_DLD (tvar_oct,args,,"TVAR: tvar for particular observation interval n")
{
        double retval;
        ColumnVector arg_samples;
        int  arg_N;
        int  arg_n;
        double inner;
        int j;
        int i;

        int nargin = args.length ();
        
        retval = 0.0;
        if (nargin !=3)
        {
                return retval;
        }

        arg_samples = args(0).vector_value ();
        arg_N = NINT(args(1).double_value ());
        arg_n = NINT(args(2).double_value ());

        

        for(j=0;j<arg_N-3*arg_n;j++)
        {
                inner = 0.0;
                for(i=0;i<arg_n;i++)
                {

                        
inner+=arg_samples(j+2*arg_n+i)-2*arg_samples(j+arg_n+i)+arg_samples(j);
                }
                retval += inner * inner;
        }
        retval = retval /(6.0*(arg_N-3*arg_n+1)*arg_n*arg_n);
        return retval;
}



reply via email to

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