Mac OS X mex uses wrong gcc compiler in compile.m #19

Open
mogenson opened this Issue Jul 7, 2011 · 3 comments

Comments

Projects
None yet
2 participants

mogenson commented Jul 7, 2011

Hello,

I get the following error when I run the patched compile.m on Mac OS X

 Mac
 /Applications/MATLAB_R2010b.app/bin/mex: line 305: gcc-4.0: command not found
 /Applications/MATLAB_R2010b.app/bin/mex: line 1041: g++-4.0: command not found

     mex: compile of ' "lk.cpp"' failed.

 ??? Error using ==> mex at 208
 Unable to complete successfully.

 Error in ==> compile at 52
     eval(['mex lk.cpp -O' include lib]);

I have gcc-4.2.1 on my computer. How can I tell Matlab or mex to use this compiler?

probably the same as this: version `GLIBCXX_3.4.14' not found in the Wiki: https://github.com/zk00006/OpenTLD/wiki/FAQ

Ask such in the google group please.

mogenson commented Jul 7, 2011

mex -setup creates a file mexopts.sh. Here's the relavent section:

  maci64)
 #----------------------------------------------------------------------------
             # StorageVersion: 1.0
             # CkeyName: GNU C
             # CkeyManufacturer: GNU
             # CkeyLanguage: C
             # CkeyVersion:
             CC='gcc-4.0'
             SDKROOT='/Developer/SDKs/MacOSX10.5.sdk'
             MACOSX_DEPLOYMENT_TARGET='10.5'
             ARCHS='x86_64'
             CFLAGS="-fno-common -no-cpp-precomp -arch $ARCHS -isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
             CFLAGS="$CFLAGS  -fexceptions"
             CLIBS="$MLIBS"
             COPTIMFLAGS='-O2 -DNDEBUG'
             CDEBUGFLAGS='-g'
 #
             CLIBS="$CLIBS -lstdc++"
             # C++keyName: GNU C++
             # C++keyManufacturer: GNU
             # C++keyLanguage: C++
             # C++keyVersion: 
             CXX=g++-4.0
             CXXFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch $ARCHS -isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
             CXXLIBS="$MLIBS -lstdc++"
             CXXOPTIMFLAGS='-O2 -DNDEBUG'
             CXXDEBUGFLAGS='-g'
 #
             # FortrankeyName: GNU Fortran
             # FortrankeyManufacturer: GNU
             # FortrankeyLanguage: Fortran
             # FortrankeyVersion: 
             FC='gfortran'
             FFLAGS='-fexceptions -m64 -fbackslash'
             FC_LIBDIR=`$FC -print-file-name=libgfortran.dylib 2>&1 | sed -n '1s/\/*libgfortran\.dylib//p'`
             FC_LIBDIR2=`$FC -print-file-name=libgfortranbegin.a 2>&1 | sed -n '1s/\/*libgfortranbegin\.a//p'`
             FLIBS="$MLIBS -L$FC_LIBDIR -lgfortran -L$FC_LIBDIR2 -lgfortranbegin"
             FOPTIMFLAGS='-O'
             FDEBUGFLAGS='-g'
 #
             LD="$CC"
             LDEXTENSION='.mexmaci64'
             LDFLAGS="-Wl,-twolevel_namespace -undefined error -arch $ARCHS -Wl,-syslibroot,$SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
             LDFLAGS="$LDFLAGS -bundle -Wl,-exported_symbols_list,$TMW_ROOT/extern/lib/$Arch/$MAPFILE"
             LDOPTIMFLAGS='-O'
             LDDEBUGFLAGS='-g'
 #
             POSTLINK_CMDS=':'
 #----------------------------------------------------------------------------

Since I don't have the Mac OS X 10.5 SDK I changed everything to 10.6 and gcc 4.2.1 but it did not work. Also the GLIBCXX_3.4.14 solution was not relevant because I don't have a libgcc_s.so.1 or libstdc++.so.6*. I did try to remove the mexopts.sh and gccopts.sh files but with without any difference.

mogenson commented Jul 7, 2011

followed the following instructions and got it to compile successfully

http://www.mathworks.com/matlabcentral/newsreader/view_thread/304392

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment