Error when building Simulink model with C mex S-function in RTW (R2010b)

조회 수: 2 (최근 30일)
Bert
Bert 2013년 12월 21일
답변: Kaustubha Govind 2014년 2월 11일
Hello,
I'm trying to build a Simulink model containing a C mex S-function with RTW (R2010b), but get following error messages related to mex function calls:
myCode.obj .text: undefined reference to '_mxSetM_700'
myCode.obj .text: undefined reference to '_mxSetN_700'
myCode.obj .text: undefined reference to '_mexCallMATLAB'
myCode.obj .text: undefined reference to '_mxDestroyArray'
myCode.obj .text: undefined reference to '_mexGetVariablePtr'
myCode.obj .text: undefined reference to '_mxGetField_700'
gmake: * [../myCode.exe] Error 111
Do I need to specify extra files in the 'Custom Code' pane of the RTW Options? Any suggestions are very appreciated.
Many thanks in advance, Bert
  댓글 수: 2
Kaustubha Govind
Kaustubha Govind 2013년 12월 30일
Do these errors show up when building code generated using RTW? Calls to MEX libraries such as mxSetM, etc. should not exist in generated code typically. Is this an un-inlined S-function?
Bert
Bert 2014년 1월 14일
The S-function is a level 2 C S-function, compiled using mex. I tried with the standard lcc compiler, as well as with VS2008 Express edition. Both result in an S-function which runs correctly in Simulink during simulation. However, when I try compiling this simulation model with RTW, the errors show up and the process is aborted.
The C S-function is indeed not inlined.

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

답변 (1개)

Kaustubha Govind
Kaustubha Govind 2014년 2월 11일
Bert: You need to modify your S-function code and remove the calls to the mxArray libraries. These libraries only run in the MATLAB environment, and therefore cannot be used in generated code meant to run standalone (without MATLAB). If you absolutely need these calls for simulation, you may write a TLC (see Inlining S-functions to define the behavior in generate code.

카테고리

Help CenterFile Exchange에서 Call MATLAB from C에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by