MATLAB: What files should I deploy when generating S-function target block in Simulink

real times-functionsimulink coder

I want to be able to use the generated S-function block in any other model, but I am not sure what files should I deploy to be able to use it and to be able to generate code from it.

Best Answer

This bug has been fixed in Release 2007b (R2007b). For previous product releases, read below for any possible workarounds:
If you use R12.1 you need to have the following files:
[sfun_name]_sf.c
[sfun_name]_sf.h
[sfun_name]_sf_common.h
[sfun_name]_sf_export.h
[sfun_name]_sf_prm.h
[sfun_name]_sf_reg.h
[sfun_name].dll
For R13 and later versions, you need to copy the sfunction generated directory [sfuncname]_sfcn_rtw, the generated wrapper C-file [sfunname]_sf.c, the generated H-file [sfunname]_sf.h and the [sfunname].dll (for R14SP2 and previous versions) or [sfunname].mexw32 (for R14SP3 and later versions).
Instead of shipping the source files, you can ship an OBJ-file that can be found under [sfuncname]_sfcn_rtw directory. This OBJ-file is not the regular [sfunname].obj that is generated in the [sfuncname]_sfcn_rtw directory.
In order to generate this OBJ-file, you need to put the S-function block in a model, generate code from the model (for GRT target, for example) and then take the [sfunname].obj that was created under the [modelname]_ grt_rtw directory.
Note that the compiler that you use to generate the S-function's OBJ-file and the compiler that you use to generate code from the target model should match.