Setting up mex to use the Visual Studio 2010 compiler

房东的猫 提交于 2019-12-03 06:13:41

It depends on what MATLAB version you are using. R2010b supports VS2010 out of the box. If you have R2010a, there is a patch available:

There are more than 1 ways of working around your problem, and only one involves money :)

  1. Buy/Upgrade to a new Matlab version (R2010b recognizes and works with VS2010).
  2. You don't have to install the full VS2008 package, the old Windows SDK v7.0 is enough. Once installed, matlab should recognize is when you do a mbuild -setup.
  3. As you yourself suggested, install VS2008.

For future reference: http://www.mathworks.com/support/compilers/R2010b/index.html

You can also make your c++ code available to Matlab without using mex. Matlab is capable of loading external DLLs and calling their functions. So you can wrap your code into a DLL, and bypass mex entirely.

Generally, I found this to be an easier way of calling C or C++ code from matlab. The drawback is that you would not have all the facilities for manipulating matlab data structures that mex provides. You can still pass data back and forth, some things are more cumbersome, such as allocating an array in C and giving the ownership of it to matlab.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!