From help-request at octave dot org Tue Jul 20 15:35:16 2004 Subject: Shared Libraries and Coda From: michaeld dot jones at pharma dot novartis dot com To: help at octave dot org Date: Tue, 20 Jul 2004 16:30:58 -0400 This is a multipart message in MIME format. --=_alternative 0070EAAC85256ED7_= Content-Type: text/plain; charset="us-ascii" I have a simple test case I am using to see how I can get custom shared libraries called from a user oct-file. I have GNU Octave, version 2.1.57 (i686-pc-linux-gnu). I used configure --enable-shared before I installed. I also have successfully installed octave-forge octave-forge-2004.07.07. I am using RedHat Linux 9. After compiling I installed libshare.so.1.0.1 and made appropriate links in /usr/local/lib. I tested the libshare.so library with a stand-alone app and it worked fine. When I run the octshare command in the directory containing the octshare.oct file in octave I get the following output. octave:1> octshare Test: Called internal method OK! octave: relocation error: /home/jonesmic/swack/test/coda2/octshare.oct: undefined symbol: _Z13getSomeNumberv Any body know what I might be missing? Here is the shared library called libshare.so which I build with the following commands: gcc -Wall -ansi -fPIC -c -g share.c gcc -shared -Wl,-soname,libshare.so.1 -o libshare.so.1.0.1 share.o $ cat share.c #include "share.h" float getSomeNumber(){ float aNumber; aNumber = 199.99; return aNumber; } $ cat share.h #ifndef _SHARE_H #define _SHARE_H #include #include float getSomeNumber(); #endif I have a simple octshare.cc file which I compile as follows mkoctfile octshare.cc -lshare [jonesmic at mojojojo coda2]$ cat octshare.cc #include #include "./share/share.h" float getSomeLocalNumber(); DEFUN_DLD(octshare, args, , "Return a number. Simple test of a share library libshare.so") { octave_value_list retval; float someNum; someNum = getSomeLocalNumber(); retval(0) = octave_value(someNum); message("Test", "Called internal method OK!"); someNum = getSomeNumber(); retval(1) = octave_value(someNum); message("Test", "Called libshare method OK!"); return octave_value(retval); } float getSomeLocalNumber(){ float someNum; someNum = 1000; return someNum; } --=_alternative 0070EAAC85256ED7_= Content-Type: text/html; charset="us-ascii"
I have a simple test case I am using to see how I can get custom shared libraries called from a user oct-file. I have GNU Octave, version 2.1.57 (i686-pc-linux-gnu). I used  configure --enable-shared before I installed. I also have successfully installed octave-forge octave-forge-2004.07.07. I am using RedHat Linux 9. After compiling I installed  libshare.so.1.0.1 and made appropriate links in /usr/local/lib.

I tested the libshare.so library with a stand-alone app and it worked fine. When I run the octshare command in the directory containing the octshare.oct file in octave I get the following output.

octave:1> octshare
Test: Called internal method OK!
octave: relocation error: /home/jonesmic/swack/test/coda2/octshare.oct: undefined symbol: _Z13getSomeNumberv

Any body know what I might be missing?


Here is the shared library called libshare.so which I build with the following commands:

gcc -Wall -ansi  -fPIC -c -g share.c
gcc -shared -Wl,-soname,libshare.so.1  -o libshare.so.1.0.1 share.o

$ cat share.c
#include "share.h"

float getSomeNumber(){
  float aNumber;
  aNumber = 199.99;
  return aNumber;
}

$ cat share.h
#ifndef _SHARE_H
#define _SHARE_H

#include <stdio.h>
#include <stdlib.h>

float getSomeNumber();

#endif

I have a simple octshare.cc file which I compile as follows

mkoctfile  octshare.cc -lshare

[jonesmic at mojojojo coda2]$ cat octshare.cc
#include <octave/oct.h>
#include "./share/share.h"
 
 float getSomeLocalNumber();

 DEFUN_DLD(octshare, args, ,
           "Return a number. Simple test of a share library libshare.so")
 {
   octave_value_list retval;
   float someNum;

   someNum = getSomeLocalNumber();
   retval(0) = octave_value(someNum);
   message("Test", "Called internal method OK!");
   
   someNum = getSomeNumber();
   retval(1) = octave_value(someNum);
   message("Test", "Called libshare method OK!");

   return octave_value(retval);
 }

 float getSomeLocalNumber(){
   float someNum;
   someNum = 1000;
   return someNum;
 } --=_alternative 0070EAAC85256ED7_=-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------