Tag Archives: Mex

An workaround for mex within MATLAB, “No supported compiler or SDK was found.”

I faced an error “No supported compiler or SDK was found.” when I tried to compile mexlised cpp file on MATLAB2015a (Mac 10.10.5).

MATLAB complains as fellow when “mex -setup” command is issued.

“No supported compiler or SDK was found.” which means that either no compiler has been installed on your system or not properly been linked with MATLAB’s mex.

The following link worked for my case and I could successfully compile mexlised cpp files.

http://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7

And the attached xcode7_mexopts

Hope this save some your time.

 

Set-up mex in MATLAB2015a within MacOS Yosemite(10.10.3)

Here is a workaround for setting up mex in MATLAB2015a within MacOS Yosemite.

You need to install two software packages: Command Line Tools (CLT) and gfortran.

1. Installation of CLT

Simply download the following and install. (You need Xcode 6.3 or higher as a prerequisite).

https://developer.apple.com/downloads/index.action?name=for%20Xcode

2. Installation of gfortlan

go to the following site and download gfortran 5.0

http://hpc.sourceforge.net/

Direct download link for gfortran 5.0

You will have gfortran-5.0-bin.tar in your downloaded folder.

Open terminal console and type the following for gfortran installation

sudo tar -xvf gfortran-5.0-bin.tar -C /.

Note that don’t forget “/.” at the end of the command line.

You will see some log messages copying files into your /usr/local/bin and related folders.

Done!

For verification, just type “mex -setup FORTRAN” in MATLAB console. This should show you the following message.

 

MEX configured to use 'gfortran' for FORTRAN language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
	 variables with more than 2^32-1 elements. In the near future
	 you will be required to update your code to utilize the
	 new API. You can find more information about this at:

http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.

MATLAB Mex in 10.9 Maverick with R2013a.

I got the following error message when compiling a Simulink S-function.

/Applications/MATLAB_R2013a.app/bin/mex: line 305: llvm-gcc-4.2: command not found

http://www.cyberbotics.com/forum?message=2406

The following thread resolves my issue and explain why the error occurs.

1. Open the /Applications/MATLAB_R2013a.app/bin/mexopts.sh file with your favorite editor. (You might need a root permission for this).

2. Change the following:

# CC='xcrun -sdk macosx10.7 clang'
CC='xcrun -sdk macosx10.8 clang'
...
# MW_SDK_TEMP="find `xcode-select -print-path` -name MacOSX10.7.sdk"
MW_SDK_TEMP="find `xcode-select -print-path` -name MacOSX10.8.sdk"
...
# MACOSX_DEPLOYMENT_TARGET='10.7'
MACOSX_DEPLOYMENT_TARGET='10.8'
...
# CXX='xcrun -sdk macosx10.7 clang++'
CXX='xcrun -sdk macosx10.8 clang++'

You also had to do “mex – setup” from MATLAB console for copying mexopts.sh to your user directory.