This page briefly documents how to configure MEX compilation environment for use with the use_dll-option of model.
Octave comes with capacities for compiling MEX-file. However, under Linux, you might have to install the liboctave-dev.
If you are using MATLAB, please check the list of supported compilers for your MATLAB version on your operating system. After installing your compiler, select it using mex -setup in Matlab and clicking on the required compiler.
Under Linux you need to have a working compilation environment installed. If not already present, it can be installed via
apt-get install build-essential
(requires root privileges). This will set up gcc
If you are using Matlab under Mac OS X, you should install the latest version of XCode
Two compilers are currently supported by Matlab: Microsoft's Visual C++ (MSVC) (free in its Commmunity edition) and, since Matlab R2015b, the MinGW-w64 C/C++ Compiler from TDM-GCC. To install this compiler, use the Add-Ons menu of MATLAB. Search for MinGW or select it from Features. For older version of MATLAB, in particular before R2014a, it may sometimes make sense to use the GNU C compiler (gcc) from Cygwin.
Under Windows when calling Dynare with the use_dll-option, you need to tell Dynare which compiler you are using:
- if you are using Microsoft Visual C++:
dynare modfilename msvc
- if you are using MinGW:
dynare modfilename mingw
- if you are using Cygwin, type at the MATLAB prompt:
dynare modfilename cygwin
Before Matlab R2014, MEX-compiling was governed by a bat-file, later versions work via (more involved) xml-files. Here, we provide a description on how to set up Cygwin using the bat-file option. If you have a newer Matlab version, you have to either figure out how to translate the bat-file settings to xml or, even better, use one of the two other compilers available.
Configuring MATLAB versions before R2014a with GNU C compiler (gcc) from Cygwin
Install a Cygwin environment (see http://www.cygwin.com). If your MATLAB is 32-bit, you need the "mingw64-i686-gcc" package. If your MATLAB is 64-bit, you need the "mingw64-x86_64-gcc" package.
Rename the configuration file to mexopts.bat, and copy it to the right directory, which will be (depending on your version of Windows):
c:\Users\<User name>\AppData\Roaming\MathWorks\MATLAB\<release number>\ (Windows 8)
c:\Users\<User name>\Application Data\MathWorks\MATLAB\<release number>\ (Windows Vista/7)
c:\Documents and Settings\<User name>\Application Data\MathWorks\MATLAB\<release number>\ (Windows XP)
Note that if you installed Cygwin in a non-standard directory (i.e. elsewhere than C:\CYGWIN), you need to edit the mexopts.bat and change the set PATH=... line accordingly.
Configuring MATLAB releases before R2010a with Microsoft Visual C++ (MSVC)
Earlier versions of Matlab before R2010a do not support Visual Studio 2010:
For Matlab 2010a there is a patch available at http://www.mathworks.de/support/solutions/en/data/1-D5W493/?solution=1-D5W493.
For versions before 2010a, use Visual C++ 2008 Express Edition, downloadable here.
For users of MATLAB 64-bit releases before R2010a, please follow these instructions for finishing the installation.