mex链接器找不到mexFunction符号

时间:2013-06-19 20:06:54

标签: matlab linker mex

直到最近,我已经能够在我的mac osx 10.8.4上编译mex函数了 但现在它给出了如下错误(为方便起见,我已经包含了整个-v调用):

**************************************************************************
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 = .)
 FILE = /Users/munanxu/Dropbox/Code/CUDA/mexThomasTDM/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/MacOS
X10.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/MacOSX
10.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 -g -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  
"inputsTest.mexmaci64"   "inputsTest.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

我已将原始的mexopts.sh文件复制到本地目录,以确保mex编译器使用的是正确的版本。我之前也使用g ++编译了我的cpp文件,以确保代码是为x86_64架构原生编译的。但是,当我尝试使用mex编译器进行编译和链接时,会出现相同的结果。 关于可能会发生什么的任何想法?似乎人们之前遇到过这个问题,但大多数都缺少库或定义。我在源文件中明确定义了一个mexFunction。

1 个答案:

答案 0 :(得分:0)

我认为Amro是正确的,我会把它作为评论,但它有点大,我发现clang command line options to select target CPU

Registered Targets:
 alpha    - Alpha [experimental]
 arm      - ARM
 bfin     - Analog Devices Blackfin [experimental]
 c        - C backend ... ...
 mblaze   - MBlaze
 mips     - Mips ...
 msp430   - MSP430 [experimental] ...
 thumb    - Thumb
 x86      - 32-bit X86: Pentium-Pro and above
 x86-64   - 64-bit X86: EM64T and AMD64
 xcore    - XCoreI'm thinking Amro is correct:

-arch x86-64正确的命令行切换,而不是x86_64