help-octave
[Top][All Lists]
Advanced

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

Interface for C libs in Octave


From: TOT
Subject: Interface for C libs in Octave
Date: Mon, 21 Jun 2010 09:47:23 -0700 (PDT)

Dear all,

Short question: How to get access to C library (have both: static and shared
with -fPIC) from Octave? I need to pass some values to some functions and
get the results. Is there any HowTo or Example of it?

Long question: I use this library to access some specially organized data.
There is no other method (except Fortran interface) to do it. The library is
huge, so I cannot just copy and paste part of the code to C extension of
Octave: I really need to call those functions and get the answers (integer,
array, matrix, string, complex, double and single precision kind of data).
The idea is to read that data using my C library, process it using Octave
functions, write it with my C library. I want to do it in Octave - because
it will be much more convenient that to do it from C (read the data using
lib, load Octave interpreter, pass and get necessary stuff, read it using
lib - looks like much less flexible). Do you have any examples of this kind
or so?

Additional information:

Let me tell you how the typical C program use my C library (lets call it
libmyclib.a - I have shared one also)

/*
Example
I skip variables declarations except the important ones
*/

#include <stdio.h>
#include <string.h>
#include <myclib.h>
main(int argc, char **argv)
{
  i = myclib_initLog(programName,RevisionID)
  if (i >0) help();
  // we asume that we know the file name: filename
  i = myclib_getType(filename,type);
  if (i>0) myclib_print('Data is corrupted');
  nd = myclib_getDim(filename,type);
  // Do some allocations and open an output file
  while (myclib_read(filename, buf, 1) == 1) {
      //do something with buf
      //end do with buf
      myclib_write(fileout, buf, 1) != 1) {
         myclib_print("Error writing to file\n");
      }
   }
  myclib_close(filename);
  myclib_close(fileout);
}

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


reply via email to

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