分类: C/C++
2012-11-30 15:50:43
问题:matlab命令行中运行mex -setup后,找不到vs2008或vs2005编译器
>> mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in D:\PROGRA~1\MATLAB\R2008a\sys\lcc\bin
[0] None
原因:matlab在识别vs的编译器时,使用的是“version"英文,而vs08显示的版本信息是“优化编译器”五个汉字,匹配不上,所以找不到。
解决方案:用记事本打开matlab/r2009a/bin/mexsetup.pm文件,找到 correc_version函数(第477行,也可用ctrl+F查找),将这个函数中的return ($version =~ /Version.$versionNumber/i);改成return ($version =~ /优化编译器.$versionNumber/i);即可。
运行结果:
>> mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in D:\PROGRA~1\MATLAB\R2008a\sys\lcc\bin
[2] Microsoft Visual C++ 2008 in d:\Program Files\Microsoft Visual Studio 9.0
[3] Microsoft Visual C++ 2005 in D:\Program Files\Microsoft Visual Studio 8
[0] None