octave-maintainers
[Top][All Lists]
Advanced

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

Re: Functions from Matlab C shared library utility


From: Alexander Barth
Subject: Re: Functions from Matlab C shared library utility
Date: Wed, 31 Jul 2013 14:34:41 +0200

Dear Reza,

In case you don't have access to matlab, here are some quick tests with the netcdf C library that I made which might he helpful for point 3.

By calling:
loadlibrary('/usr/lib/libnetcdf.so','/usr/include/netcdf.h','mfilename','testproto.m')
Matlab create a file testproto.m which include the same information than the header file (such as function name and argument type, structures and enums) but as matlab structure. It also create the "thunk" file libnetcdf_thunk_glnxa64.so on my system. With the proto file, it is no longer necessary to pass the header file when you load the library:

loadlibrary('/usr/lib/libnetcdf.so',@testproto)

The name of the "thunk" can be modified by the option thunkfilename. It seems that this file is some kind of a wrapper library.

For what it is worth I have attached the file testproto.m.
You might be interest in the library libffi (http://sourceware.org/libffi/) which is also used by python.

Parsing the header file might not be trivial. As an intermediate step, having to hand-code the proto file would already be very useful.

Cheers,
Alex


On Fri, Jul 26, 2013 at 8:58 AM, Reza Housseini <address@hidden> wrote:
Hello

I'm trying to implement the functions from Matlabs C shared library utility [1]. And I have some questions regarding this and perhaps someone can help me.

1. The function "libfunctions" displays the available functions in a library. Is there an easy way (exsisting library or program) to do such stuff? "nm" does not display function arguments for dynamic symbols and I don know from any program which can extract such information from a header file (probably need to write one).

2. The function "calllib" can execute functions from a shared library. Does there exist a conversion table of data types similar to [2]?

3. Would it make any sense to support C++ shared library with this approach? Definition of conversion between classes and Octave structs?

3. The function "loadlibrary" which loads library into workspace: can someone clarify on Matlab what the argument "@protofile" means. And also the Name-Value pairs "mfilename" and "thunkfilename"?

Thanks for any help. 

Cheers Reza



[1] http://www.mathworks.ch/ch/help/matlab/using-c-shared-library-functions-in-matlab-.html
[2] http://www.mathworks.ch/ch/help/matlab/matlab_external/passing-arguments-to-shared-library-functions.html

Attachment: testproto.m
Description: Binary data


reply via email to

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