简体   繁体   English

Matlab Mex代码未编译

[英]Matlab Mex code not compiling

I am rewriting some of my matlab code using mex and C++ to make it read large files in faster. 我正在使用mex和C ++重写一些matlab代码,以使其更快地读取大型文件。 I am trying to compile the code and get this error. 我正在尝试编译代码并得到此错误。 I am new to mex and would appreciate some help in discovering why the code won't compile. 我是mex的新手,希望能为您找到为什么代码无法编译的帮助。 Thanks in advance. 提前致谢。

>> mex -v read_svm.cpp

**************************************************************************
  Warning: 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, see:
           http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html
**************************************************************************

-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
   FILE = /Users/anb/.matlab/R2013a/mexopts.sh
----------------------------------------------------------------
->    MATLAB                = /Applications/MATLAB_R2013a.app
->    CC                    = xcrun  -sdk macosx10.7  clang
->    CC flags:
         CFLAGS             = -fno-common -arch x86_64 -isysroot         /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7    .sdk -mmacosx-version-min=10.7  -fexceptions
         CDEBUGFLAGS        = -g
         COPTIMFLAGS        = -O2 -DNDEBUG
         CLIBS              = -L/Applications/MATLAB_R2013a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
         arguments          =  -DMX_COMPAT_32
->    CXX                   = xcrun  -sdk macosx10.7  clang++
->    CXX flags:
         CXXFLAGS           = -fno-common -fexceptions -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7
         CXXDEBUGFLAGS      = -g
         CXXOPTIMFLAGS      = -O2 -DNDEBUG
         CXXLIBS            = -L/Applications/MATLAB_R2013a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
         arguments          =  -DMX_COMPAT_32
->    FC                    = gfortran
->    FC flags:
         FFLAGS             = -fexceptions -m64 -fbackslash
         FDEBUGFLAGS        = -g
         FOPTIMFLAGS        = -O
         FLIBS              = -L/Applications/MATLAB_R2013a.app/bin/maci64 -lmx -lmex -lmat -L -lgfortran -L -lgfortranbegin
         arguments          =  -DMX_COMPAT_32
->    LD                    = xcrun -sdk macosx10.7 clang
->    Link flags:
         LDFLAGS            = -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2013a.app/extern/lib/maci64/mexFunction.map
         LDDEBUGFLAGS       = -g
         LDOPTIMFLAGS       = -O
         LDEXTENSION        = .mexmaci64
         arguments          = 
->    LDCXX                 = 
->    Link flags:
         LDCXXFLAGS         = 
         LDCXXDEBUGFLAGS    = 
         LDCXXOPTIMFLAGS    = 
         LDCXXEXTENSION     = 
         arguments          = 
----------------------------------------------------------------

-> xcrun  -sdk macosx10.7  clang++ -c  -I/Applications/MATLAB_R2013a.app/extern/include -I/Applications/MATLAB_R2013a.app/simulink/include -DMATLAB_MEX_FILE -fno-common -fexceptions -arch x86_64 -isysroot     /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7  -DMX_COMPAT_32 -O2 -DNDEBUG  "read_svm.cpp"

-> xcrun -sdk macosx10.7 clang -O -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2013a.app/extern/lib/maci64/mexFunction.map -o  "read_svm.mexmaci64"  read_svm.o  -L/Applications/MATLAB_R2013a.app/bin/maci64 -lmx -lmex -lmat -lstdc++

Undefined symbols for architecture x86_64:
  "_mexFunction", referenced from:
     -exported_symbol[s_list] command line option
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

    mex: link of ' "read_svm.mexmaci64"' failed.

Error using mex (line 206)
Unable to complete successfully.

Do you have a void mexFunction(int nout, mxArray* pout[], int nin, const mxArray* pin[])) defined in read_svm.cpp file? 您在read_svm.cpp文件中定义了一个void mexFunction(int nout, mxArray* pout[], int nin, const mxArray* pin[]))吗?

Matlab expects your mex file to have a function with that signiture in your code. Matlab希望您的mex文件在代码中具有带有该签名的功能。 This is the function it then calls when you execute the mex file. 这是您执行mex文件时调用的函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM