Mex Link Failure: Undefined Symbols for Architecture
Show older comments
I am using Mac OS X 10.9, and Matlab 2013a, I'm compiling with Xcode 5.1.1 (I think, I don't know how to check). I have edited my mexopts.sh file to update all instances of 10.7 to 10.9. Now I'm getting a linker error that I see a lot of people have gotten before, however based on the answers to all the previous posts I have not gotten it to work. When I run mex -v ndfun.c this is the output I get.
>> mex -v ndfun.c
**************************************************************************
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/artinsarraf/.matlab/R2013a/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB_R2013a.app
-> CC = xcrun -sdk macosx10.9 clang
-> CC flags:
CFLAGS = -fno-common -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -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.9 clang++
-> CXX flags:
CXXFLAGS = -fno-common -fexceptions -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9
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.9 clang
-> Link flags:
LDFLAGS = -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -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.9 clang -c -I/Applications/MATLAB_R2013a.app/extern/include -I/Applications/MATLAB_R2013a.app/simulink/include -DMATLAB_MEX_FILE -fno-common -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -fexceptions -DMX_COMPAT_32 -O2 -DNDEBUG "ndfun.c"
ndfun.c:403:7: warning: implicit declaration of function 'zgemm_' is invalid in C99
[-Wimplicit-function-declaration]
BLASCALL(zgemm)("N", "N", &m, &m, &m, &cone...
^
ndfun.c:74:21: note: expanded from macro 'BLASCALL'
#define BLASCALL(f) f ## _
^
<scratch space>:207:1: note: expanded from here
zgemm_
^
ndfun.c:614:4: warning: implicit declaration of function 'dgeev_' is invalid in C99
[-Wimplicit-function-declaration]
BLASCALL(dgeev)("N", &jobvr, &m, input + i*inputstride, &m, outeigs...
^
ndfun.c:74:21: note: expanded from macro 'BLASCALL'
#define BLASCALL(f) f ## _
^
<scratch space>:207:1: note: expanded from here
dgeev_
^
2 warnings generated.
-> xcrun -sdk macosx10.9 clang -O -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.9 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2013a.app/extern/lib/maci64/mexFunction.map -o "ndfun.mexmaci64" ndfun.o -L/Applications/MATLAB_R2013a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
Undefined symbols for architecture x86_64:
"_dgecon_", referenced from:
_compute_lu in ndfun.o
"_dgeev_", referenced from:
_mexFunction in ndfun.o
"_dgemm_", referenced from:
_mexFunction in ndfun.o
"_dgetrf_", referenced from:
_compute_lu in ndfun.o
"_dgetri_", referenced from:
_mexFunction in ndfun.o
"_dgetrs_", referenced from:
_mexFunction in ndfun.o
"_zgemm_", referenced from:
_mexFunction in ndfun.o
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 ' "ndfun.mexmaci64"' failed.
I have also tried using a different compiler. I downloaded gfortran, but I don't know how to get mex to use it. Thanks for any help anyone can give. I don't have any other files related to the undefined symbols so I'm assuming it's a compiler problem as opposed to a problem with the code (which does work for other people).
Accepted Answer
More Answers (0)
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!