This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

C Libraries

Directly call C library functions from MATLAB®

A shared library is a collection of functions dynamically loaded by an application at run time. This MATLAB interface supports libraries containing functions defined in C header files. To call functions in C++ libraries, see the interface described in C++ Libraries.

Functions

loadlibraryLoad C shared library into MATLAB
unloadlibraryUnload shared C library from memory
calllibCall function in C shared library
libfunctionsReturn information on functions in shared C library
libfunctionsviewDisplay shared C library function signatures in window
libisloadedDetermine if shared C library is loaded
libpointerPointer object for use with shared C library
libstructConvert MATLAB structure to C-style structure for use with shared C library

Classes

lib.pointerPointer object compatible with C pointer

Topics

Call C Functions in Shared Libraries

How to call functions in external, shared C libraries from MATLAB.

Pass Arguments to Shared C Library Functions

How to construct MATLAB arguments compatible with the argument types found in the library functions.

Pointer Arguments

How to use libpointer to pass arguments by reference.

Structure Arguments

Requirements for passing a MATLAB structure to an external library function.

MATLAB Prototype Files

How to modify C header file information.

Troubleshooting

Limitations to Shared Library Support

C language features not supported.

Limitations Using Structures

Rules for using C language structures.

Loading Library Errors

Errors occur when the shared library is not a valid library.

No Matching Signature Error

This error occurs when you call a function without the correct input or output arguments, or if there is an error in the function signature in the header file.

MATLAB Terminates Unexpectedly When Calling Function in Shared Library

Some shared libraries, compiled as Microsoft® Windows® 32-bit libraries, use a calling convention that is incompatible with the default MATLAB calling convention.