您好我试图在Mac 10.12.3 Sierra中使用mex命令在c中编译代码:
Verbose mode is on.
Neither -compatibleArrayDims nor -largeArrayDims is selected.
Using -compatibleArrayDims. In the future, MATLAB will require the use of
-largeArrayDims and remove the -compatibleArrayDims option.
For more information:
http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
... Looking for compiler 'Xcode with Clang' ...
... Looking for environment variable 'DEVELOPER_DIR' ...No.
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer' ...Yes.
... Executing command 'which xcrun' ...Yes ('/usr/bin/xcrun').
... Looking for folder '/usr/bin' ...Yes.
... Executing command 'defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...No.
... Executing command 'defaults read /Library/Preferences/com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...Yes ('8.2.1').
... Executing command '
agreed=8.2.1
if echo $agreed | grep -E '[\.\"]' >/dev/null; then
lhs=`expr "$agreed" : '\([0-9]*\)[\.].*'`
rhs=`expr "$agreed" : '[0-9]*[\.]\(.*\)$'`
if echo $rhs | grep -E '[\."]' >/dev/null; then
rhs=`expr "$rhs" : '\([0-9]*\)[\.].*'`
fi
if [ $lhs -gt 4 ] || ( [ $lhs -eq 4 ] && [ $rhs -ge 3 ] ); then
echo $agreed
else
exit 1
fi
fi' ...Yes ('8.2.1').
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk' ...Yes.
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk' ...Yes.
... Executing command 'echo /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk | rev | cut -c1-10 | rev | egrep -oh '[0-9]+\.[0-9]+'' ...Yes ('10.12').
Found installed compiler 'Xcode with Clang'.
Options file details
-------------------------------------------------------------------
Compiler location: /Applications/Xcode.app/Contents/Developer
Options file: /Applications/MATLAB_R2016b.app/bin/maci64/mexopts/clang_maci64.xml
CMDLINE200 : /usr/bin/xcrun -sdk macosx10.12 clang -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map" /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o -O -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/c_exportsmexfileversion.map" -lmwlapack -lmwblas -L"/Applications/MATLAB_R2016b.app/bin/maci64" -lmx -lmex -lmat -lc++ -o foldin.mexmaci64
CC : /usr/bin/xcrun -sdk macosx10.12 clang
DEFINES : -DMX_COMPAT_32 -DMATLAB_MEX_FILE
MATLABMEX : -DMATLAB_MEX_FILE
MACOSX_DEPLOYMENT_TARGET : 10.9
CFLAGS : -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
INCLUDE : -I"/Applications/MATLAB_R2016b.app/extern/include" -I"/Applications/MATLAB_R2016b.app/simulink/include"
COPTIMFLAGS : -O2 -fwrapv -DNDEBUG
CDEBUGFLAGS : -g
LD : /usr/bin/xcrun -sdk macosx10.12 clang
LDFLAGS : -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map"
LDBUNDLE : -bundle
FUNCTIONMAP : "/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map"
VERSIONMAP : "/Applications/MATLAB_R2016b.app/extern/lib/maci64/c_exportsmexfileversion.map"
LINKEXPORT : -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map"
LINKEXPORTVER : -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/c_exportsmexfileversion.map"
LINKLIBS : -lmwlapack -lmwblas -L"/Applications/MATLAB_R2016b.app/bin/maci64" -lmx -lmex -lmat -lc++
LDOPTIMFLAGS : -O
LDDEBUGFLAGS : -g
OBJEXT : .o
LDEXT : .mexmaci64
SETENV : CC="/usr/bin/xcrun -sdk macosx10.12 clang"
CXX="/usr/bin/xcrun -sdk macosx10.12 clang"
CFLAGS="-fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -DMX_COMPAT_32 -DMATLAB_MEX_FILE"
CXXFLAGS="-fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -DMX_COMPAT_32 -DMATLAB_MEX_FILE"
COPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
CXXOPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
CDEBUGFLAGS="-g"
CXXDEBUGFLAGS="-g"
LD="/usr/bin/xcrun -sdk macosx10.12 clang"
LDXX="/usr/bin/xcrun -sdk macosx10.12 clang"
LDFLAGS="-Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map" -lmwlapack -lmwblas -L"/Applications/MATLAB_R2016b.app/bin/maci64" -lmx -lmex -lmat -lc++ -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map""
LDDEBUGFLAGS="-g"
DEVELOPER_DIR_CHECK :
XCODE_DIR : /Applications/Xcode.app/Contents/Developer
XCRUN_DIR : /usr/bin
XCODE_AGREED_VERSION : 8.2.1
ISYSROOT : /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
SDKVER : 10.12
MATLABROOT : /Applications/MATLAB_R2016b.app
ARCH : maci64
SRC : /Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/foldin.c;/Applications/MATLAB_R2016b.app/extern/version/c_mexapi_version.c
OBJ : /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o;/var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o
OBJS : /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o
SRCROOT : /Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/foldin
DEF : /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.def
EXP : foldin.exp
LIB : foldin.lib
EXE : foldin.mexmaci64
ILK : foldin.ilk
MANIFEST : foldin.mexmaci64.manifest
TEMPNAME : foldin
EXEDIR :
EXENAME : foldin
OPTIM : -O2 -fwrapv -DNDEBUG
LINKOPTIM : -O
CMDLINE100_0 : /usr/bin/xcrun -sdk macosx10.12 clang -c -DMX_COMPAT_32 -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2016b.app/extern/include" -I"/Applications/MATLAB_R2016b.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -O2 -fwrapv -DNDEBUG /Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/foldin.c -o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o
CMDLINE100_1 : /usr/bin/xcrun -sdk macosx10.12 clang -c -DMX_COMPAT_32 -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2016b.app/extern/include" -I"/Applications/MATLAB_R2016b.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -O2 -fwrapv -DNDEBUG /Applications/MATLAB_R2016b.app/extern/version/c_mexapi_version.c -o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o
-------------------------------------------------------------------
Building with 'Xcode with Clang'.
/usr/bin/xcrun -sdk macosx10.12 clang -c -DMX_COMPAT_32 -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2016b.app/extern/include" -I"/Applications/MATLAB_R2016b.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -O2 -fwrapv -DNDEBUG /Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/foldin.c -o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o
In file included from /Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/foldin.c:2:
/Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/fold.c:101:6: warning: implicit declaration of function 'dgemm_' is invalid in C99 [-Wimplicit-function-declaration]
DGEMM(&transa, &transb, &i_len, &m_len, &l_len, &alpha,
^
/Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/fold.c:84:16: note: expanded from macro 'DGEMM'
# define DGEMM dgemm_
^
/Users/jorge/Documents/Simulaciones/Simulaciones-Estatica/SIMULACION-ESTATICA/fold.c:279:2: warning: implicit declaration of function 'mxErrMsgTxt' is invalid in C99 [-Wimplicit-function-declaration]
mxErrMsgTxt("Sizes of folded indices do not match");
^
2 warnings generated.
/usr/bin/xcrun -sdk macosx10.12 clang -c -DMX_COMPAT_32 -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2016b.app/extern/include" -I"/Applications/MATLAB_R2016b.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -O2 -fwrapv -DNDEBUG /Applications/MATLAB_R2016b.app/extern/version/c_mexapi_version.c -o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o
/usr/bin/xcrun -sdk macosx10.12 clang -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map" /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/foldin.o /var/folders/1s/1bkm1bj15jd090r2jxl5t0gw0000gn/T/mex_9034902856557_5843/c_mexapi_version.o -O -Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/c_exportsmexfileversion.map" -lmwlapack -lmwblas -L"/Applications/MATLAB_R2016b.app/bin/maci64" -lmx -lmex -lmat -lc++ -o foldin.mexmaci64
Error using mex
Undefined symbols for architecture x86_64:
"_mxErrMsgTxt", referenced from:
_mexFunction in foldin.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
但是,我在vervose模式下获得了下一个错误:
void
mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
double *ndx1, *ndx1max, *ndx2, *ndx2max;
if (nrhs != 6) {
mexErrMsgTxt("Wrong number of arguments");
}
if (nlhs > 1) {
mexErrMsgTxt("Too many output arguments expected");
}
ndx1 = mxGetPr(prhs[2]);
if (mxGetNumberOfElements(prhs[2]) > 1) {
ndx1max = ndx1 + 1;
} else {
ndx1max = ndx1;
}
ndx2 = mxGetPr(prhs[5]);
if (mxGetNumberOfElements(prhs[5]) > 1) {
ndx2max = ndx2 + 1;
} else {
ndx2max = ndx2;
}
plhs[0] = fold(prhs[0], mxGetScalar(prhs[1]), *ndx1, *ndx1max,
prhs[3], mxGetScalar(prhs[4]), *ndx2, *ndx2max);
}
_mexFunction是以下一个:
select @message =
case
when isnull(a.sourceofpay,'') = @sop
and isnull(a.[payid],'') = @payid
and isnull(a.[paysubid],'') = @paysubid
and isnull(b.[status],'') = @cat
and isnull(c.[status],'') = @stat
and a.[csflevel] = @level then
'status match - sop, payid and subid override. out value = '
when ...
else 'default ''''' end,
@out = d.billedstat
from [dbo].[BilledStatusOverride] a
inner join [dbo].[cat277] b on a.[cat277_statusId] = b.[COUNTER]
left outer join [dbo].[stat277] c on a.[stat277_statusId] = c.[COUNTER]
inner join [dbo].[bsname] d on a.[bsname_statId] = d.[counter]
问题是程序fold.c不是我的,我不知道程序本身是否有问题,或者我没有正确使用mex命令。另一方面,我使用Xcode 8作为编译器。有人可以帮我吗?
答案 0 :(得分:0)
我在编译不是我的代码时遇到了同样的问题。只需将mxErrMsgTxt("bliblablu")
的出现替换为mexErrMsgIdAndTxt("xxx","bliblablu")
。
(参见https://www.mathworks.com/help/matlab/apiref/mexerrmsgtxt.html例如https://www.mathworks.com/help/matlab/apiref/mexerrmsgidandtxt.html)