Home > MacOS, Matlab > Config mex for Matlab on macOS

Config mex for Matlab on macOS

I have been trying a lot to make the ‘mex’ working on my mac. But a lot of errors such as can’t find the ‘float.h’, although it is there! multiple tries… finally fix this problem today 🙂

I searched a little bit and finally found this link is quite useful. Basically, you have to make some changes of the ‘mexopts.sh’ file. I have Matlab 2012a, and x-code 4 installed. I didn’t try the suggestion of downloading Xcode3, but the following suggestions work. Find the block of ;; maci64, and change MACOSX_DEPLOYMENT_TARGET to ‘10.6’. Also remove -isysroot in CFLAGS and CXXFLAGS (there are two -isysroot).  Here’s my final mexopts.sh file.

    ;;
 maci64)
 #----------------------------------------------------------------------------
 CC=gcc
 SDKROOT='/Developer/SDKs/MacOSX10.6.sdk'
 MACOSX_DEPLOYMENT_TARGET='10.6'
 ARCHS='x86_64'
 CFLAGS="-fno-common -no-cpp-precomp -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET" 
 CFLAGS="$CFLAGS -fexceptions"
 CLIBS="$MLIBS"
 COPTIMFLAGS='-O2 -DNDEBUG'
 CDEBUGFLAGS='-g'
 #
 CLIBS="$CLIBS -lstdc++"
 
 CXX=g++
 CXXFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch $ARCHS -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET" 
 CXXLIBS="$MLIBS -lstdc++"
 CXXOPTIMFLAGS='-O2 -DNDEBUG'
 CXXDEBUGFLAGS='-g'

 

 

Advertisements
Categories: MacOS, Matlab
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: