2

I had some code (c++) and I would like to generate the mex files.

is there any tutorial which tech how to setup visual studio ultimate 2012 how to build mex files?

thanks a lot

  • I haven't been able to actually try this in VS2012 yet, but maybe [this](http://stackoverflow.com/questions/16716821/how-to-build-mex-file-directly-in-visual-studio-2010) question might be of help. – j0rre Apr 15 '14 at 08:42

1 Answers1

2

I can confirm that the same steps as described in this question work for Visual Studio 2012 (and for Visual Studio 2013 too). Starting with an empty project the following settings in the project's Property Pages are necessary and sufficient to build a working .mexw64 file:

Configuration properties -> General:
    Set Target Extension to .mexw64
    Set Configuration Type to Dynamic Library (.dll)

Configureation poperties -> VC++ Directories:
    Add $(MATLAB_ROOT)\extern\include; to Include Directories

Configuration properties -> Linker -> General:
    Add $(MATLAB_ROOT)\extern\lib\win64\microsoft; to Additional Library Directories

Configuration properties -> Linker -> Input:
    Add libmx.lib;libmex.lib;libmat.lib; to Additional Dependencies

Configuration properties -> Linker -> Command Line:
    Add /export:mexFunction to Additional Options

$(MATLAB_ROOT) is the path to Matlab's root folder, eg. C:\Program Files\MATLAB\R2014a. For a 32-bit build you'd need to change both occurrences of 64 to 32.

Community
  • 1
  • 1
j0rre
  • 519
  • 1
  • 5
  • 13
  • I hope my edit justifies undeleting and removing any downvotes from an answer that provides the requested solution. – j0rre Sep 01 '14 at 13:01