Troubleshooting C/C++ Library Definition Issues
R2026bShape Value Not Found
When you use an argument to define the shape for another argument, you must define the
argument in the C++ function signature. In the example Generated Library Definition File, suppose that you
define the shape of argument in as argument
inb:
defineArgument(taskDefinition, "in", "clib.array.libname.Int", "input", "inb");
The C++ signature for function task does not have an argument
inb.
void task(int* in, double* ind, int sz, char const* inc)For more information about Size values, see Define Missing Size Property.
Invalid Shape Value Type
When you use an argument to define the shape for another argument, you must consider the
types for both arguments. In the example Generated Library Definition File, suppose that you
define argument inc as a null-terminated string:
defineArgument(taskDefinition, "inc", "string", "input", "nullTerminated");
If you define the shape of argument ind as argument
inc, MATLAB® displays an error because a string cannot be used for a numeric type.
defineArgument(taskDefinition, "ind", "clib.array.libname.Double", "input", "inc");
For more information about Size values, see Define Missing Size Property.
Why Is a Function or a Type Missing from the Definition File?
If a library contains any unsupported language features or data types, then MATLAB does not include the functionality in the library definition file.
Generated Library Definition File
For information about the error messages, refer to this example. The C++ signature is:
void task(int * in, double * ind, int sz, char const * inc)%taskDefinition = addFunction(libDef, ... % "void task(int * in,double * ind,int sz,char const * inc)", ... % "MATLABName", "clib.libname.task", ... % "Description", "clib.libname.task Representation of C++ function task."); % Modify help description values as needed. %defineArgument(taskDefinition, "in", "clib.array.libname.Int", "input", <SHAPE>); % <MLTYPE> can be "clib.array.libname.Int",or "int32" %defineArgument(taskDefinition, "ind", "clib.array.libname.Double", "input", <SHAPE>); % <MLTYPE> can be "clib.array.libname.Double", or "double" %defineArgument(taskDefinition, "sz", "int32"); %defineArgument(taskDefinition, "inc", <MLTYPE>, "input", <SHAPE>); % <MLTYPE> can be "clib.array.libname.Char","int8","string", or "char" %validate(taskDefinition);
Build Error undefined reference or unresolved external
symbol
When you build an interface by using the clibgen.generateLibraryDefinition or clibgen.buildInterface
functions, the compiler might display error messages about an undefined
reference or an unresolved external symbol. These errors
often occur when you forget to provide information about compiled library files. To include
compiled library files, use the Libraries name-value argument.
If you already called the clibgen.generateLibraryDefinition
function, you can edit the library definition file
define to fix the build error.
Search for the OutputFolder and Libraries section and fill in or modify
the libname.mlibDef.Libraries variable. Be sure to specify the full path and the
library name. Save the file, then rerun the build
function.