This also led me to some questions/discoveries about the s-function builder and generated mex files which could be helpful to document:
- The s-function builder seems to generate its files to the current matlab working folder, which means that any included library files using relative paths need to take this into account if you change the matlab working folder. This also means that if you want your matlab project's startup folder to be the root directory, you will end up having a bunch of mexw64, cpp files and whatnot directly in the root which is kind of messy.
- If you compile the same s-function into a few different locations, it looks like Simulink will update the project's dependencies to use the most recently generated mexw64 file, so you can delete the older files. But also it doesn't look like there's a way to tell Simulink to use an older mex file, so if you wanted to revert to a previous version you'll have to undo your changes to the s-function builder and recompile it.
- What is rtwmakecfg.m? Why does Simulink Compiler need this? It seems like even my top-level .slx file depends on the file.
- It seems to me that Simulink Compiler needs not only the mexw64 files, but also the cpp files generated by the s-function builder? I thought the point of generating the mex files was that I would only need those and nothing else, for the s-function to work in a simulink model. Or does Simulink only need the mex files but Simulink Compiler needs more?