Build C++ Library Interface and Review Contents
Note
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:
build(definelibName
) addpathlibName
Display the functionality in the library.
summary(definelibName)
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:
clibgen.buildInterface('header.hpp
',Verbose=true) addpathlibName
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.
clibgen.generateLibraryDefinition("A.hpp",AdditionalCompilerFlags=value)
For example, this table shows the value
to use for the C++17
standard.
AdditionalCompilerFlags=Value
Platform | Compiler a | Value for Using C++17 Standard |
---|---|---|
Windows® | Microsoft Visual C++ 2019 |
|
Windows | MinGW64 Compiler (C++) |
|
Windows | Intel Parallel Studio XE 2020 for C++ with Microsoft Visual Studio 2019 |
|
Linux® | g++ |
|
macOS | Xcode |
|
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 documentation in your system web
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
build
| clibgen.LibraryDefinition