Visual Studio 2015 编译 mex 文件
这里以64位的windows系统为例,在visual studio 2015和matlab2016a中测试通过。
配置
visual studio的具体设置如下所示:
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
调试
https://blog.csdn.net/xuexiyanjiusheng/article/details/46862635
我遇到的问题和你类似,,只不过我的没法调试,但是可以正常运行,调试时发现也是AddInitialize()函数出现问题,,最终解决是这样的,,,,在调试的时候,找到异常设置选项卡,,将里面的win32 exception去掉勾选即可。。至于异常设置选项卡在哪,你自己找找吧,我的在下方输出结果的地方。。。。。。祝好
http://www.ilovematlab.cn/thread-483558-1-1.html
参考:
https://blog.csdn.net/xueweuchen/article/details/44244403