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 Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by