该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
依照例子,写了myadd2.m如下:
function [y,z] = myadd2(a,b)
% dummy function, just to demonstrate the idea
y = a+b;
z = a+2*b;
将 Matlab 函数转成 DLL 函数:
1、用
mcc -W cpplib:libmyadd2 -T link:lib myadd2.m –v
出现以下错误,
??? Error: "cpplib:libmyadd2" is not a valid -W option argument.
Error in ==> D:\MATLAB6p5\toolbox\compiler\mcc.dll
为什么会如此?
2、用
mcc -W lib:libsum_prod -T link:lib sum_prod.m –v
出现??? Error: File "–v" not found.
Error in ==> D:\MATLAB6p5\toolbox\compiler\mcc.dll
用
mcc -W lib:libsum_prod -T link:lib sum_prod.m
出现
_lib1696.def : error LNK2001: 无法解析的外部符号 mlfMyadd2
_lib1696.def : error LNK2001: 无法解析的外部符号 mlxMyadd2
libmyadd2.lib : fatal error LNK1120: 2 个无法解析的外部命令
LINK : fatal error LNK1141: 导出文件生成期间失败
MBUILD.BAT: Error: Link of 'libmyadd2.dll' failed.
??? Error using ==> mbuild
Unable to complete successfully
??? Error: An error occurred while shelling out to mbuild (error code = 1).
Unable to build executable (specify the -v option for more information).
Error in ==> D:\MATLAB6p5\toolbox\compiler\mcc.dll
检查了,
mbuild.bat文件如下,也没有看出来什么意思呢。
@echo off
rem MBUILD.BAT
rem
rem Compile and link script used for building math library
rem standalone files.
rem
rem
rem
rem
rem -------------------------------------------------------------------
rem MATLAB root directory
rem -------------------------------------------------------------------
rem
set MATLAB=d:\MATLAB6p5
rem ------------- Do not modify anything below this line --------------
rem
rem ###################################################################
rem # Set up script location
rem ###################################################################
rem # use the installed location of mex.pl, or %0 if mbuild was called by
rem # full path name, or look for it on the DOS path.
set SCRIPTLOC=""
if not "%MATLAB%" == "" set SCRIPTLOC="%MATLAB%\bin\win32\mex.pl"
if not exist %SCRIPTLOC% set SCRIPTLOC=%0\..\mex.pl
if not exist %SCRIPTLOC% set SCRIPTLOC=%0\..\win32\mex.pl
if not exist %SCRIPTLOC% set SCRIPTLOC=-S mex.pl
rem ###################################################################
rem # Set up perl location
rem ###################################################################
rem # Either use the installed location of perl,
rem # or use %0 if mbuild was called by full path name,
rem # or search for mbuild.bat on the DOS path
rem # or hope it is on the DOS path.
set PERLLOC=""
if not "%MATLAB%" == "" set PERLLOC="%MATLAB%\sys\perl\win32\bin\perl.exe"
if not exist %PERLLOC% set PERLLOC="%0\..\..\sys\perl\win32\bin\perl.exe"
if not exist %PERLLOC% set PERLLOC="%0\..\..\..\sys\perl\win32\bin\perl.exe"
if not exist %PERLLOC% for %%x in (%PATH%) do if exist "%%x\mbuild.bat" set PERLLOC="%%x\..\..\sys\perl\win32\bin\perl.exe"
if not exist %PERLLOC% set PERLLOC=perl
rem ###################################################################
rem # Set up script arguments (to avoid %9 DOS batch file limit)