How to build mex file directly in Visual Studio 2010?

来源:互联网 发布:淘宝刷流量收藏软件 编辑:程序博客网 时间:2024/04/27 12:56

After some experimenting with guidance from this page mentioned in the question, it seems like starting with an empty C++ project the following settings in the project's Property Pages are necessary and sufficient to build a working .mexw64 from Visual Studio 2010:

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 DirectoriesConfiguration properties -> Linker -> General:    Add $(MATLAB_ROOT)\extern\lib\win64\microsoft; to Additional Library DirectoriesConfiguration properties -> Linker -> Input:    Add libmx.lib;libmex.lib;libmat.lib; to Additional DependenciesConfiguration 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\R2013a.

So far this has only been tried from a solution created from scratch and built for Matlab 2013a 64-bit. I assume that to build for 32-bit one only needs to change both occurrences of 64 to 32. I will update the post when I have confirmed that this works for an existing solution.

EDIT: As expected this works for projects added to existing solutions. Remember to set the new project to be dependent on the project that creates the library.

0 0
原创粉丝点击