Troubleshooting C++ Library Definition Issues - MATLAB & Simulink (original) (raw)
Main Content
Shape 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 argumentinb
:
defineArgument(taskDefinition, "in", "clib.array.libname.Int", "input", "inb");
The C++ signature for function task
does not have an argumentinb
.
void task(int* in, double* ind, int sz, char const* inc)
For more information about SHAPE
values, see Define Missing SHAPE Parameter.
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 argumentinc
, 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 SHAPE
values, see Define Missing SHAPE Parameter.
Why Is a Function or a Type Missing from the Definition File?
If a library contains any unsupported language features or data types, then the functionality is not included 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", ); % can be "clib.array.libname.Int",or "int32" %defineArgument(taskDefinition, "ind", "clib.array.libname.Double", "input", ); % can be "clib.array.libname.Double", or "double" %defineArgument(taskDefinition, "sz", "int32"); %defineArgument(taskDefinition, "inc", , "input", ); % 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 filedefine_`libname`_.m
to fix the build error. Search for the OutputFolder and Libraries section and fill in or modify the libDef.Libraries
variable. Be sure to specify the full path and the library name. Save the file, then rerun the build function.