Unable to create mex function 'XX_Simuli​nkfunction​_sfun.mexw​64' required for simulation.

132 次查看(过去 30 天)
I am trying to call custom c code in my stateflow and got below error
Making simulation target "XX_Simulinkfunction_sfun", ... Microsoft (R) Program Maintenance Utility Version 14.10.25019.0 Copyright (C) Microsoft Corporation. All rights reserved. NMAKE : fatal error U1065: invalid option '-' Stop.
Component:Make | Category:Make error
Unable to create mex function 'XX_Simulinkfunction_sfun.mexw64' required for simulation.
example.c
#include "example.h"
double busactive(double u1, double u2)
{
double retval;
retval = u1 + u2;
return (retval);
}
example.h
#define TRUE 1
#define FALSE 0
#define MAYBE 2
double busactive(double, double);
added #include "example.h" in simulation target Header file section and example.c is source file section.
using 2018a matlab and MEX configured to use 'Microsoft Visual C++ 2017 (C)' for C language compilation.
Could anyone help me solving this issue.

回答(3 个)

Jagtendra Kumar
Jagtendra Kumar 2019-9-6
编辑:Jagtendra Kumar 2019-9-6
try this solution :- setting requires in Configuration Parameters > Simulation Target > Adavanced Parameters > Enable Genetared typedefs for imported bus and enumeration type.

Jing Chen
Jing Chen 2021-8-20
Hi
Did you solve your problem?

weyl chen
weyl chen 2024-8-19,8:18
It's trouble for me. But I find this cause. "Unable to create mex function 'VLC_APA_sfun.mexw64' required for simulation."
I am find last. because The Enum Data type is error. I define the enum name is "Astate" 0-state1 1-state2 2-state3.
in chart if you defin the same name of inport and enum, this may error of "Unable to create mex function 'VLC_APA_sfun.mexw64' required for simulation."
e.g.
if (Astate == Astate.state1) {aa = 0;}
change this
if (Astate_in == Astate.state1) {aa = 0;} the problem is gone.
=================================================================================
问题:
“由于枚举数据类型错误,导致无法为仿真创建所需的 'VLC_APA_sfun.mexw64' MEX 函数。”
解决方案:
“我在状态图中定义了一个名为 'Astate' 的枚举类型,其值为 0-state1,1-state2,2-state3。如果在状态图中定义的枚举名称与输入端口名称相同,就可能出现 'VLC_APA_sfun.mexw64' MEX 函数创建失败的错误。例如,如果写成:
```c
if (Astate == Astate.state1) { aa = 0; }
```
会出现问题。但改成:
```c
if (Astate_in == Astate.state1) { aa = 0; }
```
问题就解决了。”
您需要确保在条件语句中使用的枚举变量名与输入端口的名称区分开来,避免命名冲突。

Community Treasure Hunt

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

Start Hunting!

Translated by