Skip to content

Instantly share code, notes, and snippets.

@amroamroamro
Last active October 4, 2017 15:36
Show Gist options
  • Save amroamroamro/414abe0b2a6002cd8945 to your computer and use it in GitHub Desktop.
Save amroamroamro/414abe0b2a6002cd8945 to your computer and use it in GitHub Desktop.
[MATLAB R2014b] MEX config files for Intel Parallel Studio XE 2015

XML configuration files for compiling MATLAB MEX-files using Intel Parallel Studio XE 2015. Tested on Windows 8.1 64-bit with MATLAB R2014b, Visual Studio 2013, and Intel Parallel Studio XE 2015.

Here is an example:

>>> mex -f intel_cpp_15_vs2013.xml -v -largeArrayDims test.cpp
>>> test()
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[])
{
    plhs[0] = mxCreateDoubleScalar(10);
}
<?xml version="1.0" encoding="UTF-8" ?>
<config
Name="Intel C++ Composer XE 2015 with Microsoft Visual Studio 2013 (C)"
ShortName="INTELC15MSVS2013"
Manufacturer="Intel"
Version="15.0"
Language="C"
Priority="A"
Location="$CROOT" >
<Details
CompilerExecutable="$COMPILER"
CompilerDefines="$COMPDEFINES"
CompilerFlags="$COMPFLAGS"
OptimizationFlags="$OPTIMFLAGS"
DebugFlags="$DEBUGFLAGS"
IncludeFlags="$INCLUDE"
LinkerExecutable="$LINKER"
LinkerFlags="$LINKFLAGS"
LinkerLibraries="$LINKLIBS"
LinkerDebugFlags="$LINKDEBUGFLAGS"
LinkerOptimizationFlags="$LINKOPTIMFLAGS"
CommandLineShell="$CROOT\bin\iclvars.bat "
CommandLineShellArg="intel64 vs2013"
CompilerDefineFormatter="/D%s"
LinkerLibrarySwitchFormatter="lib%s.lib;%s.lib"
LinkerPathFormatter="/LIBPATH:%s"
LibrarySearchPath="$$LIB;$$LIBPATH;$$PATH;$$INCLUDE;$MATLABROOT\extern\lib\$ARCH\microsoft"
/>
<!-- Switch guide: http://msdn.microsoft.com/en-us/library/fwkeyyhe(v=vs.71).aspx -->
<vars
CMDLINE100="$COMPILER /c $COMPFLAGS $OPTIM $COMPDEFINES $INCLUDE $SRC /Fo$OBJ"
CMDLINE200="$LINKER $LINKFLAGS $LINKTYPE $LINKOPTIM $LINKEXPORT $OBJS $LINKLIBS /out:$EXE"
CMDLINE250="mt -outputresource:$EXE;2 -manifest $MANIFEST"
CMDLINE300="del $EXP $LIB $MANIFEST $ILK"
COMPILER="icl"
COMPFLAGS="/Zp8 /GR /W3 /EHs /nologo /MD"
COMPDEFINES="/D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 $MATLABMEX"
MATLABMEX=" /DMATLAB_MEX_FILE"
OPTIMFLAGS="/O2 /DNDEBUG"
INCLUDE="-I&quot;$MATLABROOT\extern\include&quot; -I&quot;$MATLABROOT\simulink\include&quot;"
DEBUGFLAGS="/Z7"
LINKER="link"
LINKFLAGS="/nologo /manifest "
LINKTYPE="/DLL"
LINKEXPORT="/EXPORT:mexFunction"
LINKLIBS="/LIBPATH:&quot;$MATLABROOT\extern\lib\$ARCH\microsoft&quot; libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
LINKDEBUGFLAGS="/debug /PDB:&quot;$TEMPNAME$LDEXT.pdb&quot;"
LINKOPTIMFLAGS=""
OBJEXT=".obj"
LDEXT=".mexw64"
SETENV="set COMPILER=$COMPILER
set COMPFLAGS=/c $COMPFLAGS $COMPDEFINES $MATLABMEX
set OPTIMFLAGS=$OPTIMFLAGS
set DEBUGFLAGS=$DEBUGFLAGS
set LINKER=$LINKER
set LINKFLAGS=$LINKFLAGS /export:%ENTRYPOINT% $LINKTYPE $LINKLIBS $LINKEXPORT
set LINKDEBUGFLAGS=/debug /PDB:&quot;%OUTDIR%%MEX_NAME%$LDEXT.pdb&quot;
set NAME_OUTPUT=/out:&quot;%OUTDIR%%MEX_NAME%%MEX_EXT%&quot;"
/>
<client>
<engine
LINKLIBS="$LINKLIBS libeng.lib"
LINKEXPORT=""
LDEXT=".exe"
LINKTYPE=""
MATLABMEX=""
/>
</client>
<locationFinder>
<!-- CROOT=C:\Program Files (x86)\Intel\Composer XE 2015\ -->
<CROOT>
<and>
<envVarExists name="ICPP_COMPILER15" />
<fileExists name="$$\Bin\intel64\icl.exe" />
<dirExists name="$$\..\.." />
</and>
</CROOT>
<!-- VCROOT=C:\Program Files (x86)\Microsoft Visual Studio 12.0\ -->
<VCROOT>
<and>
<or>
<hklmExists path="SOFTWARE\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
<hkcuExists path="SOFTWARE\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
<hklmExists path="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
<hkcuExists path="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
</or>
<fileExists name="$$\bin\amd64\cl.exe" />
<dirExists name="$$\..\.." />
</and>
</VCROOT>
<!-- SDKROOT=C:\Program Files (x86)\Windows Kits\8.1\ -->
<SDKROOT>
<or>
<hklmExists path="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
<hkcuExists path="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
<hklmExists path="SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
<hkcuExists path="SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
</or>
</SDKROOT>
</locationFinder>
<env
PATH="$CROOT\bin\intel64;$VCROOT\bin\amd64;$VCROOT\vcpackages;$VCROOT\..\Common7\IDE;$VCROOT\..\Common7\Tools;$SDKROOT\bin\x64;"
INCLUDE="$CROOT\compiler\include;$VCROOT\include;$SDKROOT\Include\shared;$SDKROOT\Include\um;$SDKROOT\Include\winrt;$MATLABROOT\extern\include;"
LIB="$CROOT\compiler\lib\intel64;$VCROOT\lib\amd64;$SDKROOT\Lib\winv6.3\um\x64;$MATLABROOT\lib\win64;"
LIBPATH="$CROOT\compiler\lib\intel64;$VCROOT\lib\amd64;$VCROOT\atlmfc\lib\amd64;$SDKROOT\Lib\winv6.3\um\x64;$MATLABROOT\extern\lib\win64;"
/>
</config>
<?xml version="1.0" encoding="UTF-8" ?>
<config
Name="Intel C++ Composer XE 2015 with Microsoft Visual Studio 2013"
ShortName="IntelCPP15MSVCPP120"
Manufacturer="Intel"
Version="15.0"
Language="C++"
Priority="A"
Location="$CPPROOT" >
<Details
CompilerExecutable="$COMPILER"
CompilerDefines="$COMPDEFINES"
CompilerFlags="$COMPFLAGS"
OptimizationFlags="$OPTIMFLAGS"
DebugFlags="$DEBUGFLAGS"
IncludeFlags="$INCLUDE"
LinkerExecutable="$LINKER"
LinkerFlags="$LINKFLAGS"
LinkerLibraries="$LINKLIBS"
LinkerDebugFlags="$LINKDEBUGFLAGS"
LinkerOptimizationFlags="$LINKOPTIMFLAGS"
CommandLineShell="$CPPROOT\bin\iclvars.bat "
CommandLineShellArg="intel64 vs2013"
CompilerDefineFormatter="/D%s"
LinkerLibrarySwitchFormatter="lib%s.lib;%s.lib"
LinkerPathFormatter="/LIBPATH:%s"
LibrarySearchPath="$$LIB;$$LIBPATH;$$PATH;$$INCLUDE;$MATLABROOT\extern\lib\$ARCH\microsoft"
/>
<!-- Switch guide: http://msdn.microsoft.com/en-us/library/fwkeyyhe(v=vs.71).aspx -->
<vars
CMDLINE100="$COMPILER /c $COMPFLAGS $OPTIM $COMPDEFINES $INCLUDE $SRC /Fo$OBJ"
CMDLINE200="$LINKER $LINKFLAGS $LINKTYPE $LINKOPTIM $LINKEXPORT $OBJS $LINKLIBS /out:$EXE"
CMDLINE250="mt -outputresource:$EXE;2 -manifest $MANIFEST"
CMDLINE300="del $EXP $LIB $MANIFEST $ILK"
COMPILER="icl"
COMPFLAGS="/Zp8 /GR /W3 /EHs /nologo /MD"
COMPDEFINES="/D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 $MATLABMEX"
MATLABMEX=" /DMATLAB_MEX_FILE"
OPTIMFLAGS="/O2 /DNDEBUG"
INCLUDE="-I&quot;$MATLABROOT\extern\include&quot; -I&quot;$MATLABROOT\simulink\include&quot;"
DEBUGFLAGS="/Z7"
LINKER="link"
LINKFLAGS="/nologo /manifest "
LINKTYPE="/DLL"
LINKEXPORT="/EXPORT:mexFunction"
LINKLIBS="/LIBPATH:&quot;$MATLABROOT\extern\lib\$ARCH\microsoft&quot; libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
LINKDEBUGFLAGS="/debug /PDB:&quot;$TEMPNAME$LDEXT.pdb&quot;"
LINKOPTIMFLAGS=""
OBJEXT=".obj"
LDEXT=".mexw64"
SETENV="set COMPILER=$COMPILER
set COMPFLAGS=/c $COMPFLAGS $COMPDEFINES $MATLABMEX
set OPTIMFLAGS=$OPTIMFLAGS
set DEBUGFLAGS=$DEBUGFLAGS
set LINKER=$LINKER
set LINKFLAGS=$LINKFLAGS /export:%ENTRYPOINT% $LINKTYPE $LINKLIBS $LINKEXPORT
set LINKDEBUGFLAGS=/debug /PDB:&quot;%OUTDIR%%MEX_NAME%$LDEXT.pdb&quot;
set NAME_OUTPUT=/out:&quot;%OUTDIR%%MEX_NAME%%MEX_EXT%&quot;"
/>
<client>
<engine
LINKLIBS="$LINKLIBS libeng.lib"
LINKEXPORT=""
LDEXT=".exe"
LINKTYPE=""
MATLABMEX=""
/>
</client>
<locationFinder>
<!-- CPPROOT=C:\Program Files (x86)\Intel\Composer XE 2015\ -->
<CPPROOT>
<and>
<envVarExists name="ICPP_COMPILER15" />
<fileExists name="$$\Bin\intel64\icl.exe" />
<dirExists name="$$\..\.." />
</and>
</CPPROOT>
<!-- VCROOT=C:\Program Files (x86)\Microsoft Visual Studio 12.0\ -->
<VCROOT>
<and>
<or>
<hklmExists path="SOFTWARE\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
<hkcuExists path="SOFTWARE\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
<hklmExists path="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
<hkcuExists path="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
</or>
<fileExists name="$$\bin\amd64\cl.exe" />
<dirExists name="$$\..\.." />
</and>
</VCROOT>
<!-- SDKROOT=C:\Program Files (x86)\Windows Kits\8.1\ -->
<SDKROOT>
<or>
<hklmExists path="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
<hkcuExists path="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
<hklmExists path="SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
<hkcuExists path="SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
</or>
</SDKROOT>
</locationFinder>
<env
PATH="$CPPROOT\bin\intel64;$VCROOT\bin\amd64;$VCROOT\vcpackages;$VCROOT\..\Common7\IDE;$VCROOT\..\Common7\Tools;$SDKROOT\bin\x64;"
INCLUDE="$CPPROOT\compiler\include;$VCROOT\include;$SDKROOT\Include\shared;$SDKROOT\Include\um;$SDKROOT\Include\winrt;$MATLABROOT\extern\include;"
LIB="$CPPROOT\compiler\lib\intel64;$VCROOT\lib\amd64;$SDKROOT\Lib\winv6.3\um\x64;$MATLABROOT\lib\win64;"
LIBPATH="$CPPROOT\compiler\lib\intel64;$VCROOT\lib\amd64;$VCROOT\atlmfc\lib\amd64;$SDKROOT\Lib\winv6.3\um\x64;$MATLABROOT\extern\lib\win64;"
/>
</config>
<?xml version="1.0" encoding="UTF-8" ?>
<config
Name="Intel Visual Fortran Composer XE 2015 with Microsoft Visual Studio 2013"
ShortName="INTELF15MSVS2013"
Manufacturer="Intel"
Version="15.0"
Language="FORTRAN"
Priority="A"
Location="$FORTRANROOT" >
<Details
CompilerExecutable="$COMPILER"
CompilerDefines="$COMPDEFINES"
CompilerFlags="$COMPFLAGS"
OptimizationFlags="$OPTIMFLAGS"
DebugFlags="$DEBUGFLAGS"
IncludeFlags="$INCLUDE"
LinkerExecutable="$LINKER"
LinkerFlags="$LINKFLAGS"
LinkerLibraries="$LINKLIBS"
LinkerDebugFlags="$LINKDEBUGFLAGS"
LinkerOptimizationFlags="$LINKOPTIMFLAGS"
CommandLineShell="$FORTRANROOT\bin\ifortvars.bat "
CommandLineShellArg="intel64 vs2013"
CompilerDefineFormatter="/D%s"
LinkerLibrarySwitchFormatter="lib%s.lib;%s.lib"
LinkerPathFormatter="/LIBPATH:%s"
LibrarySearchPath="$$LIB;$$LIBPATH;$$PATH;$$INCLUDE;$MATLABROOT\extern\lib\$ARCH\microsoft"
/>
<!-- Switch guide: http://msdn.microsoft.com/en-us/library/fwkeyyhe(v=vs.71).aspx -->
<vars
CMDLINE100="$COMPILER /c $COMPFLAGS $OPTIM $COMPDEFINES $INCLUDE $SRC /Fo$OBJ"
CMDLINE200="$LINKER $LINKFLAGS $LINKTYPE $LINKOPTIM $LINKEXPORT $OBJS $LINKLIBS /out:$EXE"
CMDLINE250="mt -outputresource:$EXE;2 -manifest $MANIFEST"
CMDLINE300="del $EXP $LIB $MANIFEST $ILK"
COMPILER="ifort"
COMPFLAGS="/nologo /fpp /Qprec /fixed /MD /fp:source /assume:bscc "
COMPDEFINES="/DMATLAB_MEX_FILE"
OPTIMFLAGS="/O2 /DNDEBUG"
INCLUDE="-I&quot;$MATLABROOT\extern\include&quot; -I&quot;$MATLABROOT\simulink\include&quot;"
DEBUGFLAGS="/Z7"
LINKER="link"
LINKFLAGS=" /nologo /manifest /INCREMENTAL:NO"
LINKTYPE="/DLL"
LINKEXPORT="/EXPORT:MEXFUNCTION"
LINKLIBS="/LIBPATH:&quot;$MATLABROOT\extern\lib\$ARCH\microsoft&quot; libmx.lib libmex.lib libmat.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
LINKDEBUGFLAGS="/debug /PDB:&quot;$TEMPNAME$LDEXT.pdb&quot;"
LINKOPTIMFLAGS=""
OBJEXT=".obj"
LDEXT=".mexw64"
SETENV="set COMPILER=$COMPILER
set COMPFLAGS=/c $COMPFLAGS $COMPDEFINES $MATLABMEX
set OPTIMFLAGS=$OPTIMFLAGS
set DEBUGFLAGS=$DEBUGFLAGS
set LINKER=$LINKER
set LINKFLAGS=$LINKFLAGS /export:%ENTRYPOINT% $LINKTYPE $LINKLIBS $LINKEXPORT
set LINKDEBUGFLAGS=/debug /PDB:&quot;%OUTDIR%%MEX_NAME%$LDEXT.pdb&quot;
set NAME_OUTPUT=/out:&quot;%OUTDIR%%MEX_NAME%%MEX_EXT%&quot;"
/>
<client>
<engine
LINKLIBS="$LINKLIBS libeng.lib"
LINKEXPORT="/subsystem:console"
LDEXT=".exe"
LINKTYPE=""
MATLABMEX=""
/>
</client>
<locationFinder>
<!-- FORTRANROOT=C:\Program Files (x86)\Intel\Composer XE 2015\ -->
<FORTRANROOT>
<and>
<envVarExists name="IFORT_COMPILER15" />
<fileExists name="$$\Bin\intel64\ifort.exe" />
<dirExists name="$$\..\.." />
</and>
</FORTRANROOT>
<!-- VCROOT=C:\Program Files (x86)\Microsoft Visual Studio 12.0\ -->
<VCROOT>
<and>
<or>
<hklmExists path="SOFTWARE\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
<hkcuExists path="SOFTWARE\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
<hklmExists path="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
<hkcuExists path="SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7" name="12.0" />
</or>
<fileExists name="$$\bin\amd64\cl.exe" />
<dirExists name="$$\..\.." />
</and>
</VCROOT>
<!-- SDKROOT=C:\Program Files (x86)\Windows Kits\8.1\ -->
<SDKROOT>
<or>
<hklmExists path="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
<hkcuExists path="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
<hklmExists path="SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
<hkcuExists path="SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1" name="InstallationFolder" />
</or>
</SDKROOT>
</locationFinder>
<env
PATH="$FORTRANROOT\bin\intel64;$VCROOT\bin\amd64;$VCROOT\vcpackages;$VCROOT\..\Common7\IDE;$VCROOT\..\Common7\Tools;$SDKROOT\bin\x64;"
INCLUDE="$FORTRANROOT\compiler\include;$VCROOT\include;$SDKROOT\Include\shared;$SDKROOT\Include\um;$SDKROOT\Include\winrt;$MATLABROOT\extern\include;"
LIB="$FORTRANROOT\compiler\lib\intel64;$VCROOT\lib\amd64;$SDKROOT\Lib\winv6.3\um\x64;$MATLABROOT\lib\win64;"
LIBPATH="$FORTRANROOT\compiler\lib\intel64;$VCROOT\lib\amd64;$VCROOT\atlmfc\lib\amd64;$SDKROOT\Lib\winv6.3\um\x64;$MATLABROOT\extern\lib\win64;"
/>
</config>
@apetros
Copy link

apetros commented Sep 16, 2015

Thank you! You just saved me hours of agony :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment