Setting up a Matlab compatible MinGW compiler in Windows
Mingw64 Installer
Go to www.mingw.org; Click on Download Installer in the upper right corner of the page. A new page will pop up and the download will start after some seconds. The downloaded file name will be 'mingw-get-setup.exe' Open the installer and click on Install. Don't change the installation directory. Leave it as it is and just click on continue. Download Mingw Offline Installer Download Download MinGW-w64 - for 32 and 64 bit Windows for free. A complete runtime environment for gcc. The mingw-w64 project is a complete runtime environment for gcc to support binaries native to Windows 64-bit and 32-bit operating systems.
◼ For Matlab R2017b, MinGW 5.3 is required.
Yes, you can install mingw-w64 offline if you use MSYS2's pacman on your internet-facing machine first, then transfer the files downloaded by pacman to your offline machine. To your question, the great thing about pacman is it will grab the right versions of all dependencies. On your internet-facing machine. 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. For more information, see 'MATLAB Support for MinGW-w64 C/C Compiler'. MinGW-w64 - for 32 and 64 bit Windows sourceforge.net 翻到下面 ,找到我们需要的编译器套件 ( 64位系统推荐x8664 的版本, 32位系统 则最好先换系统,否则 只能用i686 的; (win32和posix代表线程模型,seh、sjlj、dwarf代表不同的异常处理模式,理论上都可以随便选),这里以.
Matlab R2015b up to R2017a
► Download the compiler binary file ->link: tdm64-gcc-4.9.2-3.exe
► Uncheck box 'Check for updated files on the TDM-GCC server'.
► Create a new TDM-GCC installation.
► Select 'MinGW-w64/TDM64'.
► Choose an installation directory. Default = C:TDM-GCC-64
► If you are going to write programs with parallel computations, make sure to check OpenMP in optional components - gcc.
► In front of gcc section, make sure that the correct version 4.9.2 is given; if not, you probably forgot to uncheck updates in the beginning.
Now, to inform the path of the compiler to Matlab, you can write in Matlab command-window, or directly in your m-file the following command.
Replace the given default installation path of the compiler, if you changed it.
To test whether the compiler is set correctly, type the following command in the Matlab Command Window
In Matlab R2017a, it gives you the following output:
Matlab R2017b
► Download and run mingw-w64 installer file ->link: mingw-w64-install.exe
► Select the proper version (5.3.0) and architecture (in my case 'x86_64').
► Choose the destination folder for installation (in my case 'C:mingw-w64x86_64-5.3.0-posix-seh-rt_v4-rev0') and go to next steps.
After installation, to inform the path of the compiler to Matlab, you can write in Matlab command-window, or directly in your m-file the following command.
To test whether the compiler is set correctly, type the following command in the Matlab Command Window
This should give you the following output:
Download Mingw W64 Offline Installer
Example for building mex function
In the following files, you can try to build a test mex function. Both files should be in an identical folder.
mex_function_test.cpp compile.m After running 'compile.m', you should be able to see the output message 'From C++: Hello world!' in the Matlab command window.