How do you compile a dll using the legacy code tool?

20 visualizzazioni (ultimi 30 giorni)
Cody
Cody il 2 Lug 2012
I have some old code written in C that follows the standard format and function names for a Simulink S-function. The folks that wrote this code years ago compiled these S-functions to a set of dlls for use. Now, I need to recompile these C files to 64-bit dlls. I tried building a project in Visual Studio around each C file and including all the Matlab include directories to get the Matlab required files, but I got an error thrown by a Matlab C file that said "unrecognized use" when I tried to compile this. So the only way I can think of compiling these S-functions to a dll is using the legacy_code tool. I can get the legacy_code tool to compile the C file to a mex file, but how do I get it to compile to a dll? I hope this makes sense, and thanks in advance!

Risposte (1)

TAB
TAB il 3 Lug 2012
Modificato: TAB il 4 Lug 2012
Legacy code tool is not for compiling s-function to dll. It is used to generate & build s-functions which wraps the existing c/c++ code which we want to integrate with the simulink model.
In your case, you have mentioned that, the C code you have is already a s-function. So...
  1. compile your s-function (c-code) using mex command to generate the MEX file.
  2. Create a blank model with s-function block and give above MEX file name in the s-function block.
  3. Simulate the model. Now if s-function block in the model is working as expected, you can generate a dll from the model using Simulink Coder (RTW) product.
  4. Go through below link to know more about how to generate dll from the model
  2 Commenti
Kaustubha Govind
Kaustubha Govind il 3 Lug 2012
@Cody: Just to clarify, S-functions used to have a .dll extension years ago. More recent releases compile them as MEX-files with platform-specific extensions. So what you got from the legacy code tool should be enough to run it as an S-function.
@TAB: I think Cody is using the 'compile' option in the legacy_code function.
TAB
TAB il 4 Lug 2012
@Kaustubha:
Ok. Actually, I have never used legacy code tool (LCT) to compile an existing s-function. I thought LCT can compile the s-functions which are generated by LCT only.

Accedi per commentare.

Categorie

Scopri di più su Simulink Coder in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by