S-function for static library
Show older comments
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?
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!