GNU-compiler (gcc-4.9.
2) for MATLAB
1 Software
You need to download the two software packages:
• MinGW (make sure it is the w64 version, w32 wont work)
http://sourceforge.net/projects/mingw-w64/
• gnumex
http://sourceforge.net/projects/gnumex/
2 Installation
• MinGW
When installing MinGW choose following settings when prompted
to any path you like (For me C:\Software\mingw-w64\x86 64-4.9.2-posix-seh-rt v3-rev0\mingw64\).
• gnumex
Extract the contents of gnumexX.XX.exe to a folder called gnumex. Place the folder where you want (the developer
suggests to put it in the MATLAB installation directory, which I did) and add the path to this folder and all subfolders to
the MATLAB path (For me C:\Software\MATLAB R2014b\gnumex2.06\).
Once gnumex is in the MATLAB path run ’gnumex’ in MATLAB. In the window appearing, enter the path to your MinGW
installation (the rest should already be filled out) and if necessary other values like in the picture below
and hit the ’Make options file’ button (this take a while). When done gnumex (hopefully) tells you that it successfully
created a options file.
• mex
Once gnumex finishes successful run ’mex -setup’, allow the setup to search for installed compilers and select ’gcc’ in the
suggested mingw64 directory, which should look similar to this:
>> mex −s e t u p
Welcome t o mex −s e t u p . T h i s u t i l i t y w i l l help you s e t up
a default compiler . For a l i s t o f s u p p o r t e d c o m p i l e r s , s e e
h t t p : / /www. mathworks . com/ s u p p o r t / c o m p i l e r s / R2014b / win64 . html
P l e a s e c h o o s e your c o m p i l e r f o r b u i l d i n g MEX− f i l e s :
Would you l i k e mex t o l o c a t e installed compilers [ y ] / n? y
Select a compiler :
[ 1 ] M i c r o s o f t S o f t w a r e Development K i t (SDK) 7 . 1 i n C: \ Program F i l e s ( x86 ) \ M i c r o s o f t V i s u a l S t u d i o 1 0 . 0
[ 2 ] M i c r o s o f t V i s u a l C++ 2010 i n C: \ Program F i l e s ( x86 ) \ M i c r o s o f t V i s u a l S t u d i o 1 0 . 0
[ 3 ] g c c i n C: \ S o f t w a r e \MINGW−˜1\ X86 64 ˜1.2 −P\mingw64\ b i n
[ 0 ] None
Compiler : 3
Please v e r i f y your c h o i c e s :
Compiler : gcc
L o c a t i o n : C: \ S o f t w a r e \MINGW−˜1\ X86 64 ˜1.2 −P\mingw64\ b i n
Are t h e s e c o r r e c t [ y ] / n? y
T r y i n g t o update o p t i o n s f i l e : C: \ U s e r s \ s 4 p f y r \AppData\Roaming\MathWorks\MATLAB\ R2014b \ mexopts . b a t
From t e m p l a t e : C: \ S o f t w a r e \MATLAB˜1\ b i n \ win64 \ mexopts \GNUMEXOPTS. b a t
Done . . .