help-octave
[Top][All Lists]
Advanced

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

.oct functions and shared libraries


From: Stef Pillaert
Subject: .oct functions and shared libraries
Date: Mon, 07 Jun 1999 12:32:12 +0200

Hello,

(this probably isn't really an octave question, and more a "gcc" question,
sorry...)

I have 2 .oct functions, created in .cc files (main.cc and sub.cc). They
are both perfectly usable as stand-alone .oct functions, but in main.cc I
call sub.cc. I do this by declaring (in main.cc) 
octave_value_list Fsub (const octafve_value_list& args, int nargout);

Next I compile like this:

mkoctfile sub.cc
rm sub.oct
ar rc libtest.a sub.o

mkoctfile main.cc
rm main.oct
ar rc libtest.a main.o

mkoctfile sub.o -L. -ltest
mkoctfile main.o -L. -ltest

All this works just fine. There should be cleaner ways to do this, but it
is (to me ) an easy way to compile everything to .o files, and I put them
all in the libtest.a library, so I can also use 'main.o' for later
functions. In fact, I do this in a (very simple) Makefile, where I treat
all .cc files the same way, and I don't have to worry too much about
dependencies: when the libtest.a changes, I just relink all my functions
against it, as in the last 2 lines above...)

**1: if someone has suggestions on this way of working, please do. I'm not
very familiar with c++ and linking-libraries-compiling-...

**2: more important: can I do this with a shared library (libtest.so)? How
do I do this? Just calling 'gcc -shared -o libtest.so main.o sub.o' instead
of the 'ar'-calls, and leaving all the rest to what it is, results in
errors while running the function in octave ("error in loading shared
libraries: main.oct : undefined symbol : Fsub__FRC17octave_value_listi").
However, 'nm libtest.so' shows me Fsub__FRC17octave_value_listi . Can
someone point me in the right direction? Should there be something added to
my source-code perhaps?

**3 Is there a way of creating a dynamic library with just the .oct-files
themselves in it? So that I just need this library in my path, and not all
the seperate .oct files? Or are just the .o files enough?
How do I tell octave to look for functions in this library?

These questions probably are more gcc related, but I spent a few days
looking for help on this in other places, without result...

Thanks,
Stef.



---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------



reply via email to

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