I'm trying to figure out an efficient close-loop workflow where I can:
- take a simulink model and convert/generate c++ code
- take said outputted c++ and covert it back to something that can run as a mex/S-function in Simulink
I know this seems like running in a circle but in my application it's important to test the c++ back in simulation before deploying to hardware. I'd rather not have the workflow involve any manual editing of c++ and have straight conversion back-and-forth handled by matlab.
My attempt looks like this:
% 1)
slbuild(my_model) % makes a bunch on c++ stuff in \folder\
% 2)
codebuild(codegen_path,'BuildVariant','MEX_FILE'); % generates a mex file
Part 1) seems to work (at least I see c++ outputs), but part 2) gives me the following error
Index exceeds the number of array elements (0).
Error in RTW.genMakefileAndBuild (line 173)
mexSrcFileName = lMexSourceFiles{1};
Error in codebuild (line 229)
lMakeResult = RTW.genMakefileAndBuild...