Cannot link using mex on mac os

1 次查看(过去 30 天)
Gianmaria
Gianmaria 2014-4-22
I'm trying to compile glpkmex on mac os X maverick running matlab R2012a, but when I run
mex -I../glpk/src/ -I/usr/include/c++/4.2.1 -I/usr/include -Dchar16_t=uint16_T glpkcc.cpp ../glpk/src/.libs/libglpk.a
I got this output
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 ld: library not found for -lstdc++ clang: error: linker command failed with exit code 1 (use -v to see invocation)
mex: link of ' "glpkcc.mexmaci64"' failed.
Any suggestion?
  3 个评论
Gianmaria
Gianmaria 2014-4-23
Dear Peter, you're right. it seems that I'm not able to compile MEX files at all.
Anyway this is the verbose output of mex
mex -v -I../glpk/src/ -I/usr/include/c++/4.2.1 -I/usr/include -Dchar16_t=uint16_T glpkcc.cpp ../glpk/src/.libs/libglpk.a
************************************************************************ 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/techdoc/matlab_external/bsflnue-1.html ************************************************************************
-> mexopts.sh sourced from directory (DIR = $PREF_DIR) FILE = /Users/Gianmaria/.matlab/R2012a/mexopts.sh ---------------------------------------------------------------- -> MATLAB = /Applications/MATLAB_R2012a.app -> CC = gcc -> CC flags: CFLAGS = -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs -mmacosx-version-min=10.8 -fexceptions CDEBUGFLAGS = -g COPTIMFLAGS = -O2 -DNDEBUG CLIBS = -L/Applications/MATLAB_R2012a.app/bin/maci64 -lmx -lmex -lmat -lstdc++ arguments = -Dchar16_t=uint16_T -DMX_COMPAT_32 -> CXX = g++ -> CXX flags: CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs -mmacosx-version-min=10.8 CXXDEBUGFLAGS = -g CXXOPTIMFLAGS = -O2 -DNDEBUG CXXLIBS = -L/Applications/MATLAB_R2012a.app/bin/maci64 -lmx -lmex -lmat -lstdc++ arguments = -Dchar16_t=uint16_T -DMX_COMPAT_32 -> FC = gfortran -> FC flags: FFLAGS = -fexceptions -m64 -fbackslash FDEBUGFLAGS = -g FOPTIMFLAGS = -O FLIBS = -L/Applications/MATLAB_R2012a.app/bin/maci64 -lmx -lmex -lmat -L -lgfortran -L -lgfortranbegin arguments = -Dchar16_t=uint16_T -DMX_COMPAT_32 -> LD = gcc -> Link flags: LDFLAGS = -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs -mmacosx-version-min=10.8 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2012a.app/extern/lib/maci64/mexFunction.map LDDEBUGFLAGS = -g LDOPTIMFLAGS = -O LDEXTENSION = .mexmaci64 arguments = ../glpk/src/.libs/libglpk.a -> LDCXX = -> Link flags: LDCXXFLAGS = LDCXXDEBUGFLAGS = LDCXXOPTIMFLAGS = LDCXXEXTENSION = arguments = ../glpk/src/.libs/libglpk.a ----------------------------------------------------------------
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 -> g++ -c -I../glpk/src/ -I/usr/include/c++/4.2.1 -I/usr/include -I/Applications/MATLAB_R2012a.app/extern/include -I/Applications/MATLAB_R2012a.app/simulink/include -DMATLAB_MEX_FILE -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs -mmacosx-version-min=10.8 -Dchar16_t=uint16_T -DMX_COMPAT_32 -O2 -DNDEBUG "glpkcc.cpp"
-> gcc -O -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs -mmacosx-version-min=10.8 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2012a.app/extern/lib/maci64/mexFunction.map -o "glpkcc.mexmaci64" glpkcc.o ../glpk/src/.libs/libglpk.a -L/Applications/MATLAB_R2012a.app/bin/maci64 -lmx -lmex -lmat -lstdc++
ld: library not found for -lstdc++ clang: error: linker command failed with exit code 1 (use -v to see invocation)
mex: link of ' "glpkcc.mexmaci64"' failed.
Peter Caday
Peter Caday 2014-4-24
This post mentions a potentially similar-looking problem for Mathematica.
Following that page, perhaps you could try editing mexopts.sh and change appearances of "-mmacosx-version-min=10.8" to "-mmacosx-version-min=10.6", or try changing "-lstdc++" to "-lstdc++.6"?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Synthesis 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by