Main Content


Class: clibgen.LibraryDefinition
Namespace: clibgen

Build library interface




build(libDef) validates and builds an interface from the library definition file created with the clibgen.generateLibraryDefinition function. For more information, see Steps to Publish a MATLAB Interface to a C++ Library.

If successful, the method prints an output to the Command Window. The output contains information about the interface file that is generated and any functions dropped because of validation failure. The function also displays the build log if the Verbose name-value argument in clibgen.generateLibraryDefinition is true.


expand all

Create a header file sample.hpp with these statements.

void func1(){}; 
void func2 (int){}; 
double func3(int){}; 

Generate the definition file.

C++ compiler set to 'MinGW64 Compiler (C++)'.
Definition file definesample.m contains definitions for 3 constructs supported by MATLAB.
- 3 construct(s) are fully defined.
To build the interface, call build(definesample).

The definition file completely defines the interface.

View the contents.

MATLAB Interface to sample Library

double clib.sample.func3(int32)

Build the interface.

Building interface file 'sampleInterface.dll' for clib interface 'sample'.
Interface file 'sampleInterface.dll' built in folder 'C:\Documents\MATLAB\sample'.

To use the library, add the interface file folder to the MATLAB path.

Input Arguments

expand all

Library definition, specified as a clibgen.LibraryDefinition object. libDef is the file created by clibgen.generateLibraryDefinition.

Example: build(defineschool)


Alternative Functionality

clibgen.buildInterface Function

Use the clibgen.buildInterface function instead of clibgen.generateLibraryDefinition and build if you know that MATLAB® automatically defines all class constructors, methods, data members, and functions for the library, or if undefined constructs are not required by your interface.

For more information, see Build C++ Library Interface and Review Contents.

Version History

Introduced in R2019a