I'm doing my "main" S-function based on the Matlab template with `mdlStart` `mdlOutputs`, etc, which communicates with some Ansi C files that I had, and this S-Function is used in Simulink. I compiled the files correctly with **mex** and in order to debug I'm using Visual Studio 2015. I can set and use breakpoints so everything is working fine.
The problem is, after finishing 'mdlOutputs' function, where all the contents are correctly printed into Matlab the debugging goes into a breakpoint and it goes into 'simulink.c'. After that, the Debug is broken saying that "libmex.pdb" cannot be found.
If I run the Simulink model without Visual Studio in the loop, Matlab just crashes and stops working.
So, any idea on how to check properly where it is giving me an error? Also, do you have any clue on why the process crashes after leaving `mdlOutputs` and before entering `mdlTerminate`? What happens in-between these two functions?
I'm using Windows 7, 64-bit and Matlab 2012b (I'm going to try and run it in the 2015b).
This is a classic pain point when debugging custom S‑Functions in Simulink — the crash between mdlOutputs and mdlTerminate usually means something is corrupting memory or leaving Simulink in an inconsistent state.