clibgen.generateLibraryDefinition
R2026b(Not recommended) Create definition file for C/C++ library
The recommended way to generate MATLAB® definitions for a C/C++ library is to create a clibgen.api.InterfaceConfiguration object. For more information on
updating your code, see Version
History.
Syntax
Description
The clibgen.generateLibraryDefinition function creates a
definition file with a .m file extension
used to generate a MATLAB interface to a C/C++ library. Use this function to:
Select C/C++ files that define the interface. For guidance on which syntax to use, see "Files in Your Library" in Tips.
Select configurations used by the generate step.
Optionally specify configurations to use to define arguments.
Optionally specify compiler build configuration arguments.
After creating the definition file, you optionally can modify the contents to include functionality that the function cannot automatically define.
You need a C/C++ compiler that MATLAB supports. You must build the interface library using the same compiler that was used to build the C/C++ library. If your library is completely defined by source files (does not use a compiled library file), then you can choose any supported C/C++ compiler to build the interface library. For information about your C/C++ compilers, type:
mex -setup cpp mex -setup c
Call the build
function on the definition file to create the MATLAB interface file.
clibgen.generateLibraryDefinition(
creates a definition file defined by
InterfaceGenerationFiles,Libraries=LibraryFiles)InterfaceGenerationFiles and
LibraryFiles.
The name of the definition file
is define (since R2022b).
By default, libName.mlibName is the name of the first file
specified in InterfaceGenerationFiles. For example, if you
specify a header file named mylibrary.hpp, then the function
creates a definition file named definemylibrary.m. If you
specify more than one interface generation file, then you must use the
InterfaceName name-value argument to specify
libName.
clibgen.generateLibraryDefinition(
for a library defined by multiple header files, source files, and, if required,
compiled library files.InterfaceGenerationFiles,SupportingSourceFiles=SourceFiles)
clibgen.generateLibraryDefinition(
for a library completely defined by
InterfaceGenerationFiles)InterfaceGenerationFiles. If your library includes a
compiled library file, then you must specify a Libraries
argument.
clibgen.generateLibraryDefinition(___,
creates the file using one or more name-value arguments. Use this option with
any of the input argument combinations in the previous syntaxes.Name=Value)
Use the Configuration options to specify the output folder for the definition file or the interface namespace.
Use the C++ Library Settings to specify compiler build and link options.
Use the Definition Configurations to define all specific argument types in the library.
Examples
Input Arguments
Name-Value Arguments
Limitations
Saving
LibraryDefinitionobjectdefinelibNameinto a MAT-file is not supported.Avoid non-ASCII characters in folder and filenames, as some locale settings do not support those characters. For information about locale, see Set Locale and Display Language.
Tips
To recreate a library definition file, call
clibgen.generateLibraryDefinitionwith name-value argumentOverwriteExistingDefinitionFilesset totrue. When you use this option, the function deletes the files, including edits you might have made to the files.