Cannot link using mex on mac os

4 views (last 30 days)
Gianmaria
Gianmaria on 22 Apr 2014
Commented: Peter Caday on 24 Apr 2014
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 Comments
Gianmaria
Gianmaria on 23 Apr 2014
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 on 24 Apr 2014
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"?

Sign in to comment.

Answers (0)

Categories

Find more on Data Synthesis 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!