Hello,
I am dealing with the following problem. I am developing a custom Simulink block, based on C/C++ code in an S-Function. The code itself does not depend on libraries, or better, it depends on system libraries that are included with #ifdefs brackets in order to have a cross-platform implementation of the S-function.
However, I'm figuring out how to make the S-function portable, since the files that Simulink calls are pre-compiled depending on which host run the "Build" command in the S-function builder.
I am willing to make the source code available for the user to compile, but I still cannot figure which is the best way to make the user experience smooth. With libraries, I could just save the Simulink library and send the .slx file. With S-function, I could send the .c code but then the user has to load it into the S-function builder, run build, etc... it's a bit cumbersome.
I found out that if I export a library with an S-function builder block, the code inside the block is retained when I send the library to other users. Morover, running the system automatically builds the S-function according to the architecture that is running the simulation. Is this the proper way to handle this issue? Should I send out Simulink libraries with S-function builder blocks with the portable C/C++ code inside? Or there's a better alternative?
I also don't particularly like the fact that the S-function build files are located in the current directory; is there any way to make the S-function builder output the files in a custom directory and automatically load the compile .mexXXX file from there without the user needing to tweak with the settings?