3

I need to use a function in Matlab that is defined by a dll file. I got an example that guy converted a dll to mexw32 file but i have known how I do this. I tried use loadlibrary but it didn't create any file. How I can do this?

Amro
  • 123,847
  • 25
  • 243
  • 454
ACB
  • 33
  • 1
  • 1
  • 3
  • `loadlibrary` will load a dll into MATLAB, if you want to create a mexw32 file, you'll need to create a C-MEX function, is this what you want? – macduff Jun 14 '13 at 22:03
  • Yes....how can I create a C-MEX function? – ACB Jun 18 '13 at 19:33

1 Answers1

2

loadlibrary is MATLAB's implementation of FFI services, a mechanism of calling functions in external shared libraries. It involves converting between C-types and their equivalent MATLAB data types to pass data around.

MEX-files are also a kind of dynamically linked libraries (with .mex* extension), that can be run directly in MATLAB as a regular function without any special syntax.

The difference is that it has a specific gateway routine called mexFunction, which receives both input and output as mxArray type. mxArray is an opaque type defined in mex.h header file, which is the fundamental type underlying all MATLAB data. You usually manipulate this data using functions in the MEX library API.

Amro
  • 123,847
  • 25
  • 243
  • 454
  • @ACB: I have provided links to the relevant documentation of both cases (loadlibrary and MEX-functions). It is well explained there :) – Amro Jun 18 '13 at 20:23