How to configure the mexopts.sh file in MAC 10.12.6 El Capitan
4 views (last 30 days)
Show older comments
I could not compile the c code in MATLAB 2012b on my MAC 10.12.6. When I implement the command: mex hello.c, it releases an error like:
gcc-5.3.0: command not found.
I had tried many ways to fix that problem but I failed. I have known that gcc (version 5.3.0) is existed on my MAC, but it seems to me that the MATLAB couldn't link to the gcc. I guess that the configuration in the mexopts.sh is wrong. Below is a part of the mexopts.sh file:
C='gcc-5.3.0'
SDKROOT='Applications/Xcode/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.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:
# C++keyLinkerName:
# C++keyLinkerVersion:
CXX=g++-5.3.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'
Could anyone please let me know how to solve that problem. Thank you!
0 Comments
Answers (1)
Walter Roberson
on 22 Dec 2016
Your gcc-5.3 is probably not on your path. If you are calling mex from within MATLAB then first set the PATH environment variable to include the directory that your gcc-5.3 is in. For example,
setenv('PATH', strcat(getenv('PATH'), ':/usr/local/bin'))
9 Comments
Walter Roberson
on 13 Jan 2017
Did you install XCode? If you did, then which version?
In mexopts.sh you can change
CC = gcc-5.3
to
CC = /usr/local/bin/gcc-5.3
See Also
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!