Simulink Matlab Function Block Error
2 次查看(过去 30 天)
显示 更早的评论
Hi guys, I buil simple matlab function but it's not working. I don't know how to fix this problem. I used matlab R2012a
Please help me.
"Unable to locate a C-compiler required by Stateflow and MATLAB Function blocks.
Use 'mex -setup' to select a supported C-compiler."
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/382568/image.png)
2 个评论
回答(2 个)
Sudhakar Shinde
2020-10-16
编辑:Sudhakar Shinde
2020-10-16
To run mex function you need c-compiler. simply open command window and type:
mex -setup
If c compiler is available this command will list down available compiler. Then you can choose c-compiler.
If no any compiler is available on your system, you need to install it.
Check below link for supported compilers for MATLAB R2012.
Walter Roberson
2020-10-16
If you are using 32 bit MATLAB and want to create 32 bit executables, then you can use the lcc32 compiler that is provided with that release. Just use
mex -setup
and have it select lcc .
However, normally it would already have selected lcc if you were using 32 bit MATLAB, so more likely is that you are using 64 bit MATLAB. For 64 bit MATLAB you should install Microsoft Windows SDK 7.1
Note: if you are using Windows 10, then it is difficult to install SDK 7.1 . On the other hand, MATLAB R2012a was never supported on Windows 10 -- only up to Windows 8 (and not Windows 8.1) . Installing SDK 7.1 on Windows 8 is a little bit of a nuisance but not too hard.
3 个评论
Sudhakar Shinde
2020-10-16
Here is the steps to install windows SDK 7.1:
SDK 7.1 Installation step in window 10
Windows 10 already comes with .NET framework by default, following steps need to be followed to properly install the Windows 7.1 SDK.
- If installed, uninstall all versions of windows Framework.
- If present, remove all the Redistributable packages (both x86 and x64) prior to 2010.
- Install Microsoft SDK 7.1 from below link.
- http://www.microsoft.com/en-us/download/details.aspx?id=8279
- Note: SDK will not install Visual C++ compiler which we need to install from next step.
- Install Microsoft Visual C++ 2010 compiler package from following path
- https://www.microsoft.com/en-us/download/details.aspx?id=4422
- Restart the machine
- Open Matlab and type in the following command in the prompt:
>> mex –setup
10. If the SDK was installed successfully, Matlab will produce the choice to select it.
11. Select Microsoft windows SDK7.1
Walter Roberson
2020-10-16
Historically it has been much more difficult than that. Sdk7.1 requires an older .NET version, and historically you could not install an older .NET without removing any newer versions, installing the old, and reinstalling the newer. That was possible for Windows 8. However Windows 10 did not permit .NET 4 to be uninstalled because it is core technology. That made it impossible to install the required older .NET for Sdk7.1.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Troubleshooting in MATLAB Compiler SDK 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!