本文档前面部分参考自http://blog.csdn.net/heroafei/article/details/43273373
使用Matlab2014a编译jar包时报错:
Test checkout of feature 'Compiler' failed.
经查证是因为Matlab2014a破解不全的问题
适用于已安装compiler但破解不完全的,http://download.csdn.net/detail/heroafei/8407631,下载后解压,把install.jar以及相应位数的三个文件(compiler.dll,mcc.exe,libmwservices.dll)复制到对应位置替换即可,另外把license.lic改为与MATLAB\licenses文件夹下的那个lic文件同名,复制并替换之。 MATLAB\R2014a\java\jar\install.jar MATLAB\R2014a\bin\win32\compiler.dll MATLAB\R2014a\bin\win32\mcc.exe MATLAB\R2014a\bin\win32\libmwservices.dll |
破解文件如下所示 http://download.csdn.net/detail/yang6464158/8905189
建立一个test.m文件。编译语句如下:
function y = myplus(x, y) z = x + y ;
mcc -v -B csharedlib:test test.m
为避免重名影响,建议不要用test作为名字。
得到结果:
>> mcc -v -B csharedlib:test test.m
Warning: Function display has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.
Warning: Function format has the same name as a MATLAB builtin. We suggest you
rename the function to avoid a potential name conflict.
Compiler version: 5.1 (R2014a)
Dependency analysis by REQUIREMENTS.
Begin validation of MEX files: Thu Jul 16 13:06:57 2015
End validation of MEX files: Thu Jul 16 13:06:57 2015
Parsing file "E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.m"
(Referenced from: "Compiler Command Line").
Parsing file "D:\Program Files\MATLAB\R2014a\toolbox\compiler\deploy\deployprint.m"
(Referenced from: "Compiler Command Line").
Parsing file "D:\Program Files\MATLAB\R2014a\toolbox\compiler\deploy\printdlg.m"
(Referenced from: "Compiler Command Line").
Invalid character was detected.
Deleting 0 temporary MEX authorization files.
Generating file "test.h".
Generating file "test.c".
Generating file "test.exports".
Generating file "E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\readme.txt".
Executing command: ""D:\Program Files\MATLAB\R2014a\bin\mbuild" -client mbuild -O -v -output "test" "test.c" "DEFFILE=\"test.def\"" "LINKEXPORT=\"/DLL /def:\"$DEFFILE\"\"" "LDEXT=\".dll\"" "CMDLINE250=\"mt -outputresource:$EXE;2 -manifest $MANIFEST\"""Verbose mode is on.
... Looking for compiler 'Microsoft Visual C++ 2013 Professional (C)' ...
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...Yes ('D:\Program Files\Microsoft Visual Studio 12.0\').
... Looking for file 'D:\Program Files\Microsoft Visual Studio 12.0\VC\bin\cl.exe' ...Yes.
... Looking for folder 'D:\Program Files\Microsoft Visual Studio 12.0\VC' ...Yes.
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...Yes ('C:\Program Files\Windows Kits\8.1\').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...Yes ('D:\Program Files\Microsoft Visual Studio 12.0\').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VC7' 12.0 ...Yes ('D:\Program Files\Microsoft Visual Studio 12.0\VC\').
... Looking for environment variable 'VS120COMNTOOLS' ...Yes ('D:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\').
... Looking for file 'D:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe' ...Yes.
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...Yes ('D:\Program Files\Microsoft Visual Studio 12.0\').
... Looking for file 'D:\Program Files\Microsoft Visual Studio 12.0\VC\vcvarsall.bat' ...Yes.
... Looking for folder 'D:\Program Files\Microsoft Visual Studio 12.0\VC' ...Yes.
Found installed compiler 'Microsoft Visual C++ 2013 Professional (C)'.
Options file details
-------------------------------------------------------------------
Compiler location: D:\Program Files\Microsoft Visual Studio 12.0\VC\..\
Options file: C:\Users\Tztek\AppData\Roaming\MathWorks\MATLAB\R2014a\MBUILD_C_win32.xml
CMDLINE100 : cl /c -MD -Zp8 -GR -W3 -EHsc- -Zc:wchar_t- -nologo -O2 -DNDEBUG /DMSVC /DIBMPC /D_CRT_SECURE_NO_DEPRECATE -I"D:\Program Files\MATLAB\R2014a\extern\include" -I"D:\Program Files\MATLAB\R2014a\extern\include\win32" E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.c /FoC:\Users\Tztek\AppData\Local\Temp\mex_59559485446525_9640\test.obj
CMDLINE200 : link /nologo /manifest /DLL /def:"test.def" C:\Users\Tztek\AppData\Local\Temp\mex_59559485446525_9640\test.obj /LIBPATH:"D:\Program Files\MATLAB\R2014a\extern\lib\win32\microsoft" mclmcrrt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /out:E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.dll
CMDLINE250 : mt -outputresource:E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.dll;2 -manifest E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.dll.manifest
CMDLINE300 : del E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.dll.manifest "E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.map"
COMPILER : cl
COMPFLAGS : -MD -Zp8 -GR -W3 -EHsc- -Zc:wchar_t- -nologo
COMPDEFINES : /DMSVC /DIBMPC /D_CRT_SECURE_NO_DEPRECATE
MATLABMEX :
OPTIMFLAGS : -O2 -DNDEBUG
INCLUDE : -I"D:\Program Files\MATLAB\R2014a\extern\include" -I"D:\Program Files\MATLAB\R2014a\extern\include\win32"
DEBUGFLAGS : /Z7
LINKER : link
LINKFLAGS : /nologo /manifest
LINKTYPE :
LINKEXPORT : /DLL /def:"test.def"
LINKLIBS : /LIBPATH:"D:\Program Files\MATLAB\R2014a\extern\lib\win32\microsoft" mclmcrrt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
LINKDEBUGFLAGS : /debug /PDB:"E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.pdb"
LINKOPTIMFLAGS :
OBJEXT : .obj
LDEXT : .dll
SETENV : set COMPILER=cl
set COMPFLAGS=/c -MD -Zp8 -GR -W3 -EHsc- -Zc:wchar_t- -nologo /DMSVC /DIBMPC /D_CRT_SECURE_NO_DEPRECATE
set OPTIMFLAGS=-O2 -DNDEBUG
set DEBUGFLAGS=/Z7
set LINKER=link
set LINKFLAGS=/nologo /manifest /export:%ENTRYPOINT% /LIBPATH:"D:\Program Files\MATLAB\R2014a\extern\lib\win32\microsoft" mclmcrrt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /DLL /def:"test.def"
set LINKDEBUGFLAGS=/debug /PDB:"%OUTDIR%%MEX_NAME%.dll.pdb"
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
VCROOT : D:\Program Files\Microsoft Visual Studio 12.0\VC
SDKROOT : C:\Program Files\Windows Kits\8.1\
VSINSTALLDIR : D:\Program Files\Microsoft Visual Studio 12.0\
VCINSTALLDIR : D:\Program Files\Microsoft Visual Studio 12.0\VC\
PROF_ENV : D:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
VCVARSALLDIR : D:\Program Files\Microsoft Visual Studio 12.0\VC
MATLABROOT : D:\Program Files\MATLAB\R2014a
ARCH : win32
SRC : E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.c
OBJ : C:\Users\Tztek\AppData\Local\Temp\mex_59559485446525_9640\test.obj
OBJS : C:\Users\Tztek\AppData\Local\Temp\mex_59559485446525_9640\test.obj
SRCROOT : E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test
DEF : C:\Users\Tztek\AppData\Local\Temp\mex_59559485446525_9640\test.def
EXP : E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.exp
LIB : E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.lib
EXE : E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.dll
ILK : E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.ilk
MANIFEST : E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.dll.manifest
TEMPNAME : E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test
EXEDIR : E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\
EXENAME : test
DEFFILE : test.def
OPTIM : -O2 -DNDEBUG
LINKOPTIM :
-------------------------------------------------------------------
Building with 'Microsoft Visual C++ 2013 Professional (C)'.
Set PATH = D:\Program Files\Microsoft Visual Studio 12.0\VC\Bin;D:\Program Files\Microsoft Visual Studio 12.0\VC\Bin\VCPackages;D:\Program Files\Microsoft Visual Studio 12.0\VC\..\Common7\IDE;D:\Program Files\Microsoft Visual Studio 12.0\VC\..\Common7\Tools;C:\Program Files\Windows Kits\8.1\\Bin\x86;;D:\Program Files\MATLAB\R2014a\bin\win32;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SDKs\TypeScript\1.0\;d:\Program Files\MATLAB\R2014a\runtime\win32;d:\Program Files\MATLAB\R2014a\bin;d:\Program Files\MATLAB\R2014a\polyspace\bin;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;D:\opencv\build\x86\vc12\bin;C:\Program Files\TortoiseSVN\bin;E:\迅雷下载\libemgucv-windows-universal-2.4.10.1940\bin;C:\Program Files\MATLAB\MATLAB Compiler Runtime\v83\runtime\win32;C:\Program Files\EsafeNet\Cobra DocGuard Client
Set INCLUDE = D:\Program Files\Microsoft Visual Studio 12.0\VC\INCLUDE;D:\Program Files\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE;C:\Program Files\Windows Kits\8.1\\include\shared;C:\Program Files\Windows Kits\8.1\\include\um;C:\Program Files\Windows Kits\8.1\\include\winrt;D:\Program Files\MATLAB\R2014a\extern\include;
Set LIB = D:\Program Files\Microsoft Visual Studio 12.0\VC\Lib;D:\Program Files\Microsoft Visual Studio 12.0\VC\ATLMFC\Lib;C:\Program Files\Windows Kits\8.1\\lib\winv6.3\um\x86;D:\Program Files\MATLAB\R2014a\lib\win32;
Set LIBPATH = D:\Program Files\Microsoft Visual Studio 12.0\VC\Lib;D:\Program Files\Microsoft Visual Studio 12.0\VC\ATLMFC\Lib;
cl /c -MD -Zp8 -GR -W3 -EHsc- -Zc:wchar_t- -nologo -O2 -DNDEBUG /DMSVC /DIBMPC /D_CRT_SECURE_NO_DEPRECATE -I"D:\Program Files\MATLAB\R2014a\extern\include" -I"D:\Program Files\MATLAB\R2014a\extern\include\win32" E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.c /FoC:\Users\Tztek\AppData\Local\Temp\mex_59559485446525_9640\test.obj
test.c
link /nologo /manifest /DLL /def:"test.def" C:\Users\Tztek\AppData\Local\Temp\mex_59559485446525_9640\test.obj /LIBPATH:"D:\Program Files\MATLAB\R2014a\extern\lib\win32\microsoft" mclmcrrt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /out:E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.dll
正在创建库 E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.lib 和对象 E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.exp
mt -outputresource:E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.dll;2 -manifest E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.dll.manifest
Microsoft (R) Manifest Tool version 6.3.9600.17029
Copyright (c) Microsoft Corporation 2012.
All rights reserved.
del E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.dll.manifest "E:\迅雷下载\31118430[emuch.net]WinFormCallMatlab\C#调用Matlab动态链接库\test.map"
MEX completed successfully.
同时产生了相应的c文件lib文件和dll文件