Contenu principal

Appeler C à partir de MATLAB

Appeler directement les fonctions d’une bibliothèque C depuis MATLAB® R2021b ou version antérieure avec la fonction calllib

Une bibliothèque partagée est une collection de fonctions chargées de manière dynamique par une application au run time.

Remarque

Utilisez cette interface MATLAB dans MATLAB R2021b ou version antérieure pour appeler les fonctions d’une bibliothèque C. L’approche recommandée pour appeler les fonctions de bibliothèques C et C++ consiste à créer une interface MATLAB vers la bibliothèque. Pour plus d’informations, consultez Appeler C/C++ à partir de MATLAB. (depuis R2022a)

Fonctions

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

Rubriques

Résolution des problèmes

Limitations to Shared Library Support

C language features not supported.

Limitations Using Structures

Rules for using C language structures in a shared library.

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.