Compiler sdk failed to genereate cpp shared library for handle class

14 次查看(过去 30 天)
classdef MyPosition < handle
%MYPOSITION Position class
% Copyright 2021 The MathWorks, Inc.
X (1,1) double {mustBeReal}
Y (1,1) double {mustBeReal}
function obj = MyPosition(X,Y)
X (1,1) double {mustBeReal}
Y (1,1) double {mustBeReal}
obj.X = X;
obj.Y = Y;
Matlab compiler sdk supports creation of an C++ MATLAB Data API shared library from strongly typed MATLAB classes.However, the code attached with the official documentation uses the value class, so I modified it a little bit to make it a handle class, as shown above. But the compiler sdk app reports error:
Preparing Runtime...
mcc -W 'cpplib:calculatearea,generic' -T link:lib -d D:\Learn\matlabSDK\strongly_typed_noNameSpace\output\cpp_compilerSDK_GUI -v D:\Learn\matlabSDK\strongly_typed_noNameSpace\MyPosition.m
Compiler version: 8.3 (R2021b)
Analyzing file dependencies.
Error: Failed to generate file "D:\Learn\matlabSDK\strongly_typed_noNameSpace\output\cpp_compilerSDK_GUI\calculateareav2.hpp".
mcc failed.
The error log was quite simple so I did not know what to do. The error dispeared, however, if I simply deleted "<handle" to make a value class back again. My question is: Is this a limitation of matlab compiler sdk that it can only deal with value class? Or did I miss something like an option flag that needs to be set?


ChullBull 2023-11-8,8:04
The MATLAB Compiler SDK does support generating C++ MATLAB Data API shared libraries from both value classes and handle classes. The error you encountered is not related to the class type (value or handle), but rather to a specific issue in the code or the compilation process.
I was able to create the shared library with the handle class , below is the attached image.
To troubleshoot the error you encountered, consider the following steps:
  1. Verify Compiler Compatibility: Confirm that the version of MATLAB Compiler SDK you are using is compatible with your MATLAB version (R2021b in your case). Check the MathWorks documentation or contact MathWorks support to ensure compatibility.
  2. Check Compiler Command: Review the command you used to compile the class. Make sure you are using the correct options and flags for generating the C++ shared library. Double-check that the paths and filenames are accurate.
  3. Clean and Rebuild: If the error persists, try performing a clean build by deleting any previously generated files and rebuilding the shared library from scratch. This can help eliminate any potential conflicts or issues from previous compilation attempts.
Hope it helps.

更多回答(0 个)


Help CenterFile Exchange 中查找有关 Troubleshooting in MATLAB Compiler SDK 的更多信息




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by