0

直到最近,我还能够在我的 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。

4

1 回答 1

0

我认为 Amro 是正确的,我会将此作为评论,但它有点大,我发现这是用于选择目标 CPU 的 clang 命令行选项

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

于 2013-06-19T20:29:57.753 回答