MinGW-w64 Compiler
You can use the MinGW-w64 compiler to build MEX files, a MATLAB® interface to a C++ library, and standalone MATLAB engine and MAT-file applications. To install the compiler, use the Add-Ons menu.
The compiler that came with Dev C seems to be not perhaps updated or is old and it does not seem to support some code structures(e.g. You can't define an integer variable inside a for statement), So I wanted to use the MinGW GCC compiler for Dev C, after downloading it, I just browsed to MinGW. MinGW-w64 - for 32 and 64 bit Windows. Hardware Network Security Cloud Software Development Artificial Intelligence. You can contact me via: Email (required) Phone SMS. I agree to receive these communications from SourceForge.net. I understand that I. Using GCC with MinGW. In this tutorial, you configure Visual Studio Code to use the GCC C compiler (g) and GDB debugger from Mingw-w64 to create programs that run on Windows. After configuring VS Code, you will compile and debug a simple Hello World program in VS Code.
On the MATLAB Home tab, in the Environment section, click Add-Ons > Get Add-Ons.
Search for MinGW or select from Features.
Alternatively, download the compiler from the File Exchange article 'MATLAB Support for MinGW-w64 C/C++ Compiler'.
Building yprime.c
Example
You can test the MinGW® compiler by building the yprime.c
example. Copy the source file to a writable folder.
If you only have the MinGW compiler installed on your system, the mex
command automatically chooses MinGW. Go to the next step. However, if you have multiple C or C++ compilers, use mex -setup
to choose MinGW.
Build the MEX file.
MATLAB displays a “Building with” message showing what compiler was used to build the MEX file.
Run the function.
For more information, see Troubleshooting and Limitations Compiling C/C++ MEX Files with MinGW-w64.
MinGW Installation Folder Cannot Contain Space
Mingw W64 Download
Do not install MinGW in a location with spaces in the path name. For example, do not use:
Mingw 5.0.3 Dev C Download
Instead, use:
Updating MEX Files to Use MinGW Compiler
Dev C++ Online
If you have MEX source files built with a different MATLAB-supported compiler, you might need to modify the code to build with the MinGW compiler. For example:
Library (
.lib
) files generated by Microsoft® Visual Studio® are not compatible with MinGW.Object cleanup is not possible when an exception is thrown using the
mexErrMsgIdAndTxt
function from C++ MEX files, resulting in memory leak.An uncaught exception in C++ MEX files compiled with MinGW causes MATLAB to crash.
MEX files with variables containing large amounts of data cannot be compiled, as the compiler runs out of memory.