Compiling mex files with Visual Studio 2013

Configuration: Matlab 2015b, Visual Studio 2013, Intel 64bit machine.

In Visual Studio do the following:
1) File -> New Project; Select location and name; in the project type, select NVIDIA -> CUDA 8.0 (choose your CUDA version as appropriate);

2) Project -> Properties -> Configuration Manager -> Active Solution Platform -> choose x64;

3) Project -> Properties -> Configuration -> Release (possibly optional);

4) Project -> Properties -> Configuration Properties -> CUDA C/C++ -> Device -> Code Generation -> compute_35, sm_35 (choose as appropriate according to your card’s compute capability);

5) Project -> Properties -> Configuration Properties -> General -> Set Target Extension -> .mexw64;

6) Project -> Properties -> Configuration Properties -> General -> Configuration Type -> Dynamic Library (.dll);

7) Project -> Properties -> Configuration Properties -> General -> Use of MFC -> Use MFC in a Shared DLL;

8) Project -> Properties -> VC++ Directories -> Include Directories -> Add: C:\Program Files\MATLAB\R2015b\extern\include;

9) Project -> Properties -> Configuration properties -> Linker -> General -> Additional Library Directories -> Add: C:\Program Files\MATLAB\R2015b\extern\lib\win64\microsoft;

10) Project -> Properties -> Configuration properties -> Linker -> Input -> Additional Dependencies -> Add: libmx.lib; libmex.lib; libmat.lib;

11) Project -> Properties -> Configuration properties -> Linker -> Command Line -> Additional Options -> Add: /export:mexFunction

The .mexw64 file can be found in the ..\x64\Release project directory.

We expect that this procedure will work also for Visual Studio 2010 and Visual Studio 2012 and for other Matlab versions.

Leave a Reply

Your email address will not be published. Required fields are marked *