Matlab 执行编译 Mex 问题

\u5982\u4f55\u5c06Matlab\u7a0b\u5e8f\u7f16\u8bd1\u6210exe\u6587\u4ef6\u65b9\u6cd5\u4ecb\u7ecd

\u6211\u4e5f\u662f\u6700\u8fd1\u624d\u641e\u5b9a\u7684\u8fd9\u4e2a\u95ee\u9898\uff0c\u6309\u4e0b\u8ff0\u6b65\u9aa4\u8fdb\u884c\uff0c\u5c31\u6ca1\u6709\u95ee\u9898\uff0c\u6211\u5df2\u7ecf\u8fd0\u884c\u6210\u529f\uff0c\u4f46\u662f\u9047\u5230\u4f60\u7a0b\u5e8f\u7684bug\u7684\u8bdd\uff0c\u4fbf\u4f1a\u51fa\u73b0\u9519\u8bef\uff0c\u5173\u95ed\u6574\u4e2a\u7a0b\u5e8f
\u5e0c\u671b\u8fd9\u4e9b\u5bf9\u4f60\u6709\u7528

\u5982\u4f55\u5c06MATLAB\u7a0b\u5e8f\u7f16\u8bd1\u6210\u72ec\u7acb\u53ef\u6267\u884c\u7684\u7a0b\u5e8f\uff1f\u5982\u4f55\u5c06\u7f16\u8bd1\u597d\u7684\u72ec\u7acb\u53ef\u6267\u884c\u7a0b\u5e8f\u53d1\u5e03\u5728\u6ca1\u6709\u5b89\u88c5MATLAB\u7684\u7535\u8111\u4e0a\uff1f\u4e0b\u9762\u5c06\u4e00\u6b65\u6b65\u5b9e\u73b0\uff1a

\u4e00\u3001\u751f\u6210\u72ec\u7acb\u53ef\u6267\u884c\u7684\u7a0b\u5e8f\uff08exe\u6587\u4ef6\uff09\u6b65\u9aa4

1\u3001\u5b89\u88c5\u7f16\u8bd1\u5668\u3002\u53ef\u6709\u591a\u79cd\u9009\u62e9\uff0cmatlab\u81ea\u5e26\u4e86\u4e00\u4e2aLCC\uff0c\u63a8\u8350\u4f7f\u7528VC++6.0\uff0c\u6211\u57fa\u4e8eVS 2003\u5b9e\u73b0\u3002
2\u3001\u8bbe\u7f6e\u7f16\u8bd1\u5668\u3002\u5728matlab\u547d\u4ee4\u884c\u8f93\u5165mbuild \u2013setup\u4ee5\u53camex \u2013setup\uff0c\u9009\u62e9\u5b89\u88c5\u7684c\u7f16\u8bd1\u5668\u3002
3\u3001\u8c03\u7528\u7f16\u8bd1\u5668\u3002\u6b64\u5904\u4f7f\u7528MATLAB\u4e0b\u7684\u4e00\u4e2aGUI\u5e73\u53f0deploytool\u4e0b\u5b8c\u5168\u5b9e\u73b0\u3002\u5728\u547d\u4ee4\u7a97\u53e3\u8f93\u5165deploytool\u5373\u53ef\u770b\u5230\u3002\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u8bf7Help\u3002
\u5f53\u7136\uff0c\u4e5f\u53ef\u4ee5\u8f93\u5165mcc -m filaname\uff0c filaname\u4e3a\u8981\u8f6c\u6210exe\u7684m\u6587\u4ef6\uff1b
\u6ce8\uff1a\u5728\u4ee5\u524d\u7684\u7248\u672c\u4e2d\uff0c\u7528\u7f16\u8bd1\u547d\u4ee4mcc -B sglcpp filaname\uff1b\u81ea2006\u7684\u7248\u672c\u540e\uff0c\u66ff\u6362\u4e3amcc -mfilaname\uff1b
4\u3001\u5b89\u88c5\toolbox\compiler\deploy\win32\u76ee\u5f55\u4e0b\u7684MCRInstaller\u3002

\u4e8c\u3001\u8131\u79bbmatlab\u8fd0\u884c\u53ef\u6267\u884c\u7a0b\u5e8f
MCR\u662f\u7531matlab\u7684\u8fd0\u884c\u73af\u5883\uff0c\u5360\u7528\u4e0d\u5230300M\u7684\u5bf9\u4e8e\u7528\u4e0d\u540cmatlab\u7248\u672c\u751f\u6210\u7684exe\u6587\u4ef6\uff0cMCR\u7248\u672c\u4e5f\u4f1a\u6709\u4e0d\u540c\uff0c\u56e0\u6b64\uff0c\u5728\u7a0b\u5e8f\u6253\u5305\u65f6\uff0c\u6700\u597d\u5c06\u76f8\u5e94\u7248\u672c\u7684MCR\u4e00\u8d77\u6253\u5305\u3002MCR\u73af\u5883\u7684\u8bbe\u7f6e\u6587\u4ef6\u5b58\u653e\u76ee\u5f55\u5982\u4e0b\uff1a
\toolbox\compiler\deploy\win32
\u6587\u4ef6\u540d\u4e3aMCRInstaller.exe\u3002\u53ef\u5c06\u5176\u62f7\u8d1d\u5230\u81ea\u5df1\u7684\u6587\u4ef6\u5939\u4e2d\uff0c(7.0\u4ee5\u524d\u7684\u7248\u672c\u662fmglinstaller.exe)\u3002
\u5728MATLAB\u91cc\u8fd0\u884c\u53ef\u6267\u884c\u7a0b\u5e8f\u7684\u529e\u6cd5\u662f\u5728\u524d\u9762\u52a0\u4e00\u4e2a\uff01\uff0c\u6bd4\u5982\uff1a!picshow\uff0c\u540e\u7f00\u540d\u53ef\u6709\u53ef\u65e0\u3002
\u5728\u5176\u5b83\u6ca1\u6709\u5b89\u88c5matlab\u7684\u673a\u5668\u4e0a\u8fd0\u884cexe\u6587\u4ef6\u524d\uff1a
\u9996\u5148\u5b89\u88c5matlab\u7684\u8fd0\u884c\u73af\u5883\u3002\u5728\u540c\u4e00\u673a\u5668\u4e0a\u53ef\u4ee5\u5e76\u5b58\u4e0d\u540c\u7248\u672c\u7684matlab\u73af\u5883(\u6362\u53e5\u8bdd\u8bf4\u4e0d\u540c\u7248\u672c\u4e0d\u517c\u5bb9)\u3002
\u5176\u6b21\u662f\u8981\u5c06\u201cMCRinstaller.exe\u5b89\u88c5\u76ee\u5f55\runtime\win32\u201d\u8fd9\u4e2a\u8def\u5f84\u6dfb\u52a0\u5230\u8be5\u8ba1\u7b97\u673a\u7684\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u901a\u5e38\u662f\u81ea\u52a8\u52a0\u8f7d\u3002
\u5982\u679c\u6ca1\u6709\uff0c\u4e5f\u53ef\u624b\u52a8\u5b89\u88c5\uff0c\u6dfb\u52a0\u7684\u65b9\u6cd5\u662f\uff1a
\u53f3\u51fb\u201c\u6211\u7684\u7535\u8111\u201d\u201c\u5c5e\u6027\u201d\u201c\u9ad8\u7ea7\u201d\u201c\u73af\u5883\u53d8\u91cf\u201d\u201c\u6dfb\u52a0\u201d\u6307\u5b9a\u4e00\u4e2a\u53d8\u91cf\u540d\uff0c\u7136\u540e\u5c06\u4e0a\u8ff0\u8def\u5f84\u590d\u5236\u5230\u91cc\u9762\u5c31\u53ef\u4ee5\u4e86\u3002
\u6ce8\uff1a\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u4f1a\u5f39\u51fa\u8ba9\u5b89\u88c5Microsoft.NETFramework\u53ef\u4ee5\u4e0d\u7528\u5b89\u88c5\u3002
\u6700\u540e\u5c31\u662f\u5c06\u7f16\u8bd1\u751f\u6210\u7684\u76f8\u76f8\u5173\u6587\u4ef6\u62f7\u8d1d\u5230\u540c\u4e00\u76ee\u5f55\u4e0b\uff0c\u53cc\u51fb\u5373\u53ef\u8fd0\u884c\u3002
\u95ee\u9898\uff1a\u76ee\u524d\u6b64\u65b9\u6cd5\u53ef\u5b8c\u5168\u8fd0\u884c\u5728\u6ca1\u6709\u5b89\u88c5MATLAB\u4ee5\u53caC/C++\u7684\u7535\u8111\u4e0a\uff0c\u4f46\u662f\u5982\u679c\u662f\u5728AMD\u7684CPU\u53ef\u4ee5\u8fd0\u884c\uff0c\u4f46\u662f\u4e0d\u4f1a\u51fa\u73b0\u4efb\u4f55MATLAB\u7f16\u8bd1\u7684\u754c\u9762\u3002
\u7f8e\u4e2d\u4e0d\u8db3\u5c31\u662f\uff0c\u8fd0\u884c\u7684\u65f6\u5019dos\u7684\u90a3\u4e2a\u9ed1\u8272\u5730\u7a97\u53e3\u4e00\u76f4\u5b58\u5728\u3002\u4e0b\u9762\u5c06\u5b9e\u73b0\u53bb\u9664\u9ed1\u5c4f\u7684\u529e\u6cd5\uff1a

\u6d88\u9664\u8fd0\u884cMATLAB\u751f\u6210\u7684exe\u7a0b\u5e8f\u7684dos\u9ed1\u5c4f\u7684\u529e\u6cd5
\u57fa\u4e8eMATLAB\u751f\u6210exe\u6587\u4ef6\u540e\uff0c\u6bcf\u6b21\u8fd0\u884c\u90fd\u5b58\u5728dos\u9ed1\u5c4f\u7684\u95ee\u9898\uff0c\u73b0\u5728\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u89e3\u51b3\uff1a
\u65b9\u6cd5\u4e00\uff1a \u5728\u547d\u4ee4\u7a97\u53e3\u8f93\u5165\uff1a
cd(prefdir)
edit compopts.bat
\u5728\u6253\u5f00\u7684\u6587\u4ef6\u6700\u540e\u6dfb\u52a0\u4ee5\u4e0b\u8bed\u53e5\uff1a

A.VC\u73af\u5883\u4e0b\uff1a

set LINKFLAGS=%LINKFLAGS%/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup

B.LCC\u73af\u5883\u4e0b:
set LINKFLAGS=%LINKFLAGS% -subsystemwindows

1. \u5b89\u88c5
\u5355\u72ec\u5b89\u88c5\u3001\u548cMATLAB\u540c\u65f6\u5b89\u88c5\u3002
2. \u8bbe\u7f6e\uff08\u4ee5vs2005\u4e3a\u4f8b\uff09
>> mbuild -setup
Please choose your compiler for building standalone MATLAB applications:

Would you like mbuild to locate installed compilers [y]/n? y

Select a compiler:
[1] Lcc-win32 C 2.4.1 in D:\PROGRA~1\MATLAB\R2010a\sys\lcc
[2] Microsoft Visual C++ 2008 SP1 in D:\Program Files\Microsoft Visual Studio 9.0
[3] Microsoft Visual C++ 2005 SP1 in C:\Program Files\Microsoft Visual Studio 8

[0] None

Compiler: 3

Please verify your choices:

Compiler: Microsoft Visual C++ 2005 SP1
Location: C:\Program Files\Microsoft Visual Studio 8

Are these correct [y]/n?

Trying to update options file: C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R2010a\compopts.bat
From template: D:\PROGRA~1\MATLAB\R2010a\bin\win32\mbuildopts\msvc80compp.bat

Done . . .

3. \u4f7f\u7528
\uff081\uff09\u5728 MATLAB \u73af\u5883\u4e2d\u4f7f\u7528 mcc \u547d\u4ee4\uff1b
\uff082\uff09\u5728\u7cfb\u7edf\u547d\u4ee4\u73af\u5883\u4e2d\u4f7f\u7528 mcc.exe \uff08\u5728Windows\u4e0a\uff09\uff1b
\uff083\uff09\u5728 MATLAB \u73af\u5883\u4e2d\u4f7f\u7528 Deployment Tool\u3002
4. \u7a0b\u5e8f\u53d1\u5e03
\uff081\uff09\u4f7f\u7528 MATLAB \u547d\u4ee4 builder\uff1b
\uff082\uff09\u4f7f\u7528 Deployment Tool \u56fe\u5f62\u5316\u5de5\u5177\u3002
\u4e00\u822c\u6765\u8bf4\uff0c\u9700\u8981\u53d1\u5e03\u7684\u6587\u4ef6\u67093\u4e2a\uff1a
\uff081\uff09\u7f16\u8bd1\u5f97\u5230\u7684\u53ef\u6267\u884c\u6587\u4ef6\u6216\u5e93\u51fd\u6570\uff1b
\uff082\uff09CTF \u6587\u4ef6\uff1b
\uff083\uff09MCRInstaller.zip\u3002
\u5728\u6700\u7ec8\u7528\u6237\u7684\u8ba1\u7b97\u673a\u4e0a\uff0c\u9996\u5148\u9700\u8981\u628aMCRInstaller.zip \u89e3\u538b\uff0c\u5e76\u628a MCR \u4e2d\u53ef\u6267\u884c\u6587\u4ef6\u6240\u5728\u76ee\u5f55\u6dfb\u52a0\u5230\u7cfb\u7edf\u8def\u5f84\u4e0a\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528\u7f16\u8bd1\u540e\u7684\u7a0b\u5e8f\u4e86\u3002

  1. 这不是错误,只是个警告罢了。大致意思就是matlab版本更新后,可能你用到的有些函数或改名之类的,一般这种warning不影响使用。

  2. 你直接运行libSVM即可,如报错贴上来。

  3. 其实libSVM作者提供了编译好的mex文件。如果不适合你的环境你再自己编译,否则用他的即可。



扩展阅读:matlab怎么单步执行 ... matlab怎么执行脚本 ... matlab编译器怎么调出来 ... matlab runtime 干啥的 ... 中英文自动翻译器 ... matlab代码生成器 ... matlab执行命令按哪个 ... matlab7.0运行按钮在哪里 ... matlab怎么执行命令 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网