Target Language Compiler    

Generate Code Using a Wrapper

To create a wrapper for external function my_alg.c, you need to construct a TLC file that embodies its calling function, wrapsfcn.c. The TLC file must generate C code that provides

To create a wrapper for my_alg(), do the following:

  1. Open the file change_wrapsfcn.tlc in your editor, and add lines of code where comments indicate to create a workable wrapper.
  2. Save the edited file as wrapsfcn.tlc. It must have the same name as the S-function block that uses it or the TLC won't be called to inline code.
  3. Inform Simulink that your code has an external reference to be resolved. To update the model's parameters, in the MATLAB command window type
  4. Click Build Model (or type Ctrl+B) to create the stand-alone application.
  5. If all went well, run the new stand-alone application and verify that it yields identical results as prior executions:

If you had any problems building the application:

As a last resort, look at wrapsfcn.tlc in the solutions/tlc_solution directory, also listed below:

Look at the highlighted lines. Did you declare my_alg() as extern double? Did you call my_alg() with the proper input and output? Correct any mistakes you may have made and build the model again.


  Generate Code Without a Wrapper Code Generation Architecture