How to build mex file directly in Visual Studio 2010?

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 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\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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值