- compile your s-function (c-code) using mex command to generate the MEX file.
- Create a blank model with s-function block and give above MEX file name in the s-function block.
- 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.
- Go through below link to know more about how to generate dll from the model
How do you compile a dll using the legacy code tool?
조회 수: 20 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (1개)
TAB
2012년 7월 3일
편집: TAB
2012년 7월 4일
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...
댓글 수: 2
Kaustubha Govind
2012년 7월 3일
@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
2012년 7월 4일
@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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!