2013-06-19 30 views
0

直到最近我已經能夠在我的mac osx 10.8.4 上編譯mex函數,但現在它給了我如下錯誤(爲了方便起見,我已經包括了整個-v調用):mex鏈接器找不到mex功能符號

************************************************************************** 
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。

+0

此外,這不是唯一的這個特定的文件,似乎隻影響我的OSX機器。我已經嘗試了許多不同的正確的源文件來找到相同的錯誤,並且我可以在Windows上編譯好。 – muxu526

+0

如何再次運行'mex -setup'來重新創建'mexopts.sh'文件,並刪除任何本地版本。我沒有Mac,所以我不知道這是否重要,但要確保您的系統具有兼容的編譯器:http://www.mathworks.com/support/compilers/R2013a/index.html?sec=maci64 – Amro

回答

0

我認爲荷銀是正確的,我會把這個作爲一個評論,但它是一個有點大,我覺得這是爲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

+0

應該是。我正在運行xcode 4.6,而我的cpu是一個沙質橋樑i7。 – muxu526

+0

對不起,我的意思是,'x86-64'而不是'x86_64' – macduff

+0

通常你不應該手動編輯這些東西,'mex -setup'應該找出正確的標誌(假設你選擇了一個支持的編譯器)。問題在於是否支持'clang'或是否需要'gcc'?我聽說Xcode現在默認帶有clang。 – Amro