MATLAB Answers

Error when doing Real-Time Simulink in External Mode "Unable to create mex function"

48 ビュー (過去 30 日間)
Sajad  A.Anbaran
Sajad A.Anbaran 2019 年 10 月 21 日
回答済み: Sajad A.Anbaran 2019 年 10 月 23 日
Dear Sir/Madame,
I am trying to do Real-Time simulatation of a vehicle model that is built in simscape.
I have already done all prepration and configuration needed to perform RT simulation. Moreover, I have successfully simulated a pure EV model in Target Computer. So all the connection are okay. Now, I want to do the same with Engine-based model but I receive the following error message.
What causes this error? Thank you.
"Making simulation target "ICE_PID_test1_v2_rt_sfun", ... Microsoft (R) Program Maintenance Utility Version 14.00.23918.0 Copyright (C) Microsoft Corporation. All rights reserved. ### Compiling "ICE_PID_test1_v2_rt_sfun.c" cl.exe /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /I "C:\Program Files\MATLAB\R2016b\extern\include" /I "C:\Program Files\MATLAB\R2016b\simulink\include" /I "C:\Program Files\MATLAB\R2016b\simulink\include\sf_runtime" /I "C:\Program Files\MATLAB\R2016b\stateflow\c\mex\include" /I "C:\Program Files\MATLAB\R2016b\rtw\c\src" /I "D:\Documents\MATLAB-simulation\xPC Target\slprj\_sfprj\ICE_PID_test1_v2_rt\_self\sfun\src" "ICE_PID_test1_v2_rt_sfun.c" ICE_PID_test1_v2_rt_sfun.c c:\program files\matlab\r2016b\extern\include\tmwtypes.h(788): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Bin\amd64\cl.exe"' : return code '0x2' Stop.
Component:Make | Category:MakeerrorOpen
Unable to create mex function 'ICE_PID_test1_v2_rt_sfun.mexw64' required for simulation."

  0 件のコメント


回答 (2 件)

Sajad  A.Anbaran
Sajad A.Anbaran 2019 年 10 月 23 日
I managed to solve this problem.
The cause of this error was the missing headers in C compiler, 'stddef.h' . I use Microsoft Visual C++ 2015 pro. I added the headers and libraries and now it works fine.
Two lessons I learned here:
1) read the error message in full. it often provides the clue to identify and resolve the problem.
2) it is imperative that you are sure about your model accuracy and all the configurations of host- target is good. it would help to elimnate many possiblities during troubleshooting of the error message.

  0 件のコメント


Diego Kuratli
Diego Kuratli 2019 年 10 月 21 日
Are you using Simulink Real-Time as System target file in your model Configuration Parameters?
Try to clear the SLRT compiler:
>> slrtsetCC('VisualC','')
Then, select the compiler by using
>> mex -setup
Delete all build files and folders in your workspace, and try to build again your model.

  3 件のコメント

Sajad  A.Anbaran
Sajad A.Anbaran 2019 年 10 月 22 日
Dear Diego,
Thank you for your response.
1) system target file is set to 'slrt.tlc'.
2) I did what you advised but still I receive the same error message. Attachments are screenshots of model configuration parameters and MATLAB command window.
3) I have already performed the similar process successfully with an electric car. the host-target setting, model configration setting and etc are same. It works with electric car, I can build the model and run it in real-time target. But, it does not for engine-based car. Could it be because of some blocks in the model? for you consideration, I used simscape libraries, and stateflow to build the model.
Diego Kuratli
Diego Kuratli 2019 年 10 月 22 日
I would try to comment out part of the models, one after the other, and see which one causes the issue.
Sajad  A.Anbaran
Sajad A.Anbaran 2019 年 10 月 23 日
Sure, I will try that. Meanwhile, I'd like to draw your attention to this part of the error message
"fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory NMAKE"
To my understanding, this part of message indicates that C++ compiler does not have 'stddef.h' library. Could this be the cause of the error?
Thank you for your time!


Community Treasure Hunt

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

Start Hunting!

Translated by