help-octave
[Top][All Lists]
Advanced

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

Shared Libraries and Coda


From: michaeld . jones
Subject: Shared Libraries and Coda
Date: Tue, 20 Jul 2004 16:30:58 -0400


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

address@hidden 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;
 }
reply via email to

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