S-function for static library

조회 수: 2 (최근 30일)
Vasyl Varvolik
Vasyl Varvolik 2020년 4월 28일
댓글: Vasyl Varvolik 2020년 5월 4일
Dear all,
I am trying to generate S-function for static library which is built in Code composer studio using Legacy Code Tool .
I took a simple example, but get an error like this:
### Start Compiling ex_doubleit
mex('ex_doubleit.c', '-IC:\Users\User\Documents\MATLAB\DoubleItLib', 'C:\Users\Vasyl Varvolik\Documents\MATLAB\DoubleItLib\Debug\DoubleItLib.lib')
Building with 'MinGW64 Compiler (C)'.
Error using mex
C:\Users\VASYLV~1\AppData\Local\Temp\mex_111404873555618_24800\ex_doubleit.obj:ex_doubleit.c:(.text+0x2704): undefined
reference to `doubleIt'
C:\Users\VASYLV~1\AppData\Local\Temp\mex_111404873555618_24800\ex_doubleit.obj:ex_doubleit.c:(.text+0xd0): undefined
reference to `doubleIt'
collect2.exe: error: ld returned 1 exit status
Error in legacycode.LCT/compile
Error in legacycode.LCT.legacyCodeImpl
Error in legacy_code (line 103)
[varargout{1:nargout}] = legacycode.LCT.legacyCodeImpl(action, varargin{1:end});
Error in Legacy_Code_Tool (line 57)
legacy_code('compile', def);
My m-file:
def = legacy_code('initialize')
def.HeaderFiles = {'DoubleItLib.h'};
def.HostLibFiles = {'DoubleItLib.lib'};
def.LibPaths = {'C:\Users\User\Documents\MATLAB\DoubleItLib\Debug'};
def.Options.language = 'C';
def.SFunctionName = 'ex_doubleit';
def.OutputFcnSpec = 'void doubleIt(double u1, double y1[1])';
legacy_code('sfcn_cmex_generate', def);
legacy_code('compile', def);
The library was built successfully in Code composer project:
* DoubleItLib.h
void doubleIt(double inVa, double *outVal);
#endif /* INCLUDE_DOUBLEITLIB_H_ */
* main.c
*/
void doubleIt(double inVal, double *outVal)
{
*outVal=2*(inVal);
}
Is it enough to use just library and header?

채택된 답변

Mark McBroom
Mark McBroom 2020년 5월 4일
The library you built in Code COmposer studio is for a TI processor. S-Functions are built to run on Windows ( or LInux) and therefore can only be linked to libraries built for the same platform. If you want to use the library with your s-function, you will have to compile it with the same mingw64 compiler that Simulink uses to create the S-Function.
  댓글 수: 1
Vasyl Varvolik
Vasyl Varvolik 2020년 5월 4일
Totally agree. Thanks a lot!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by