Simulink Matlab Function Block Error
2 views (last 30 days)
Show older comments
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."
2 Comments
Answers (2)
Sudhakar Shinde
on 16 Oct 2020
Edited: Sudhakar Shinde
on 16 Oct 2020
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
on 16 Oct 2020
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 Comments
Sudhakar Shinde
on 16 Oct 2020
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
on 16 Oct 2020
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.
See Also
Categories
Find more on Introduction to Installation and Licensing 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!