Main Content

Build C++ Library Interface and Review Contents


If library functionality is missing, the library might contain unsupported language features or data types. For details, run clibgen.generateLibraryDefinition with the Verbose option set to true.

Build From Library Definition File

If you created a library definition file by using the clibgen.generateLibraryDefinition function, then use the build function. For example, for library definition file definelibName, type:

addpath libName

Display the functionality in the library.


One-Step Build

If your library does not contain pointers or other constructs that require definition, you do not need to create a definition file. Call clibgen.buildInterface directly on the C++ header and library files. For example, to build library libName defined by header file header.hpp, type:

addpath libName

Specify C++ Compiler Standard

Your library might use C++ language constructs which are not supported by the default standard of your selected compiler. For details, see Microsoft C/C++ language conformance by Visual Studio version. To specify the C++ compiler standard for building your interface, use the AdditionalCompilerFlags name-value argument.


For example, this table shows the value to use for the C++17 standard.





Value for Using C++17 Standard

Windows®Microsoft Visual C++ 2019


WindowsMinGW64 Compiler (C++)


WindowsIntel Parallel Studio XE 2020 for C++ with Microsoft Visual Studio 2019






a For information about supported compilers, see Supported and Compatible Compilers.

Specify Compiler and Linker Flags

To pass specific compiler and linker flags to the function building an interface, use the AdditionalCompilerFlags or AdditionalLinkerFlags name-value arguments in clibgen.generateLibraryDefinition or clibgen.buildInterface. The function passes these flags to the compiler and linker without any validation. The publisher needs to know how the flags affect the build process.

Review Contents of Interface

MATLAB® automatically copies some C++ comments, if available, from the header and source files into the interface. You can modify or replace this content. For more information, see Publish Help Text for MATLAB Interface to C++ Library.

Use the doc function to open the Help browser which provides links to display help for library functionality. For example, to verify the included classes for library libname, type:

doc clib.libname

Click a link for a class. MATLAB opens a new tab. To display help for class ClassName, click the Constructor Summary link and verify the content. Click the Property Summary links. Scan the Method Summary for clib.libname.ClassName methods.

Build Interface for Debugging

For more information, see Debug C++ Library from MATLAB Interface.

See Also


Related Topics