help-octave
[Top][All Lists]
Advanced

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

Re: Interface for C libs in Octave


From: TOT
Subject: Re: Interface for C libs in Octave
Date: Thu, 24 Jun 2010 01:41:38 -0700 (PDT)

Is here anyone who can help me with interface my library with Octave?
Please help me!

The behaving of my library is very much the same as libpng. 
Except it reads and produces other kind of binaries.

So if anyone can show me how to interface to libpng or to some other that
kind of libraries,
then I can reproduce it for my library.

I promise that I'll post here a tutorial about my work, once I'll finish it.

Please help!

Now I do the following steps:

1. I compiled shared library using -fPIC option (the library was static).

2. I checked it using ldd and nm for a function which I need to call from
Octave:
    nm libmyclib.so | grep -i myfunc, and get:
    0000000000020130 T myfunc
    
    That means that the symbols are there and my function can be recognized
easily.

3. Let me call this function myfunc.
                   definition of it is:
                                          double myfunc();
   so it takes no parameter and returns a double precision floating point
value.

4. The lib is now in /opt/myclib/lib and header file is in
/opt/myclib/include

5. Then I go to my extension file for Octave:
                    #include <octave/oct.h>
                    extern "C" {
                    #include <myclib.h>
                    // I tried this double myfunc() too;
                    }
                    //And this too: #include <myclib.h>
                    DEFUN_DLD (myfunction, args, nargout,
                    "My function from myclib")
                    {
                     int nargin = args.length ();
                     double t = 1.0;
                     t = cddx_wtime();
                     int n = 1;
                     n = (int) t;
                     octave_stdout << "Hello World has " << nargin 
                     << " input arguments and "
                     << nargout << " output arguments.\n"
                     << "and the time is" << n << " !\n";
                     return octave_value_list ();
                     }
6. I use mkoctfile together with all include and libs paths and list of
libraries.
7. Everything compiles fine. But when I do nm simple.oct | grep -i myfunc I
get U myfunc which means that my function is undefined... I get the same
error in the octave window (undefined symbol).
8. I tried to use generic calls (from verbose output of mkoctave):
    g++ -c -fPIC -I/usr/include/octave-3.0.5
-I/usr/include/octave-3.0.5/octave -O2 -g -I/opt/myclib/include -I.
simple.cc -o simple.o
    g++ -fPIC -shared -Wl,-Bsymbolic -o simple.oct simple.o
-L/usr/lib/octave-3.0.5 -loctinterp -loctave -lcruft
-Wl,-Bsymbolic-functions -llapackgf-3 -lblas-3gf -lfftw3 -lreadline
-lncurses -ldl -lhdf5 -lz -lm -lgfortranbegin -lgfortran -L/opt/myclib/lib/
-Bdynamic -lmyclib -lgomp -lpthread
9. The result is the same :-(

Please point me to the solution of this problem!
You are my only hope indeed...

Thanks in Advance and Best Regards,
Anar Z. Yusifov.

-----
Back to the future!
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/Interface-for-C-libs-in-Octave-tp2262929p2266632.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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