MATLAB: How to create C library (‘.lib’ file) from the model in Real-Time Workshop 6.6 (R2007a)

ertlibrarieslibrarysimulink coderstatic

I would like to be able to create C library ('.lib' file) from my model. Using 'ert_shrlib.tlc' target, it is possible to create shared library (.dll files). I would like to know if it is possible to generate a '.lib' file too.

Best Answer

While using the shared library target 'ert_shrlib.tlc', by default '.lib' files are not created. However, you can change the default behavior and retain the '.lib' file by modifying the corresponding template makefile (TMF). For example in the template make file 'ert_vc.tmf' line 347 mentions that:
"#--- Comment out the next line to retain .lib and .exp files ---"
If you comment out the next line in this file, '.lib' and '.exp' files are retained. However, please note that if you do this, the generated 'model.h' file will need a small modification to be used together with the generated 'ert_main.c' for implicit linking. For example, if you are using the Microsoft Visual C++ development system, you will need to declare' __declspec(dllimport)' in front of all data to be imported implicitly from the shared library file.
This is also mentioned in the document. Please run the following command in MATLAB to see the documentation for this:
web([docroot,'/toolbox/ecoder/ug/bq2nslk-1.html#bq2nufb-1'])