help-octave
[Top][All Lists]
Advanced

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

Re: Using C files with OCtave


From: Ludovic Pénet
Subject: Re: Using C files with OCtave
Date: Mon, 9 May 2005 07:42:21 -0500

Le lundi 09 mai 2005 à 21:59 +1000, SITI HAJAR A BAKAR a écrit :
> Hello all,
> I have a file written in C which i wish to call in a '.m file' from 
> Octave. I am using Octave in Windows XP and Octave 2.1.69
> I have absolutely no idea where to start. The manuals dont really give  
> me a guide.
> ive tried to open directly the gcc and g++ applications I've downloaded 
> but they wont open. The Octave manual says I can only link C++ files to 
> octave, and must use 'wrapper' functions to wrap files written in C 
> before they are compiles in the C++ compiler.
> Is this still true? I would appreciate any hints or tips. Thank you so 
> much!
I think you juste have to compile your C code with gcc, then write a
wrapper such as :

#ifndef octave_oct_h
#include <octave/oct.h>
#endif

/* ... */

DEFUN_DLD(func name, args,, "Func name")
{
  octave_value_list ovlList;
  Matrix matdRes;
  octave_value ovlMat = args(0);
  int iFilterOrder = args(1).int_value();

 /* processing */

  ovlList.append(matdRes);
 return ovlList
}

then use mkoctfile to build your module.

If you have many functions to wrap, you might be interested by matwrap
(http://lnc.usc.edu/~holt/matwrap/).

Best regards,

Ludovic



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

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