MATLAB Answers

Mex on macosx without xcode

48 views (last 30 days)
Magnus on 14 Oct 2016
Commented: Art on 15 Jan 2019
I want to compile mex files without installing xcode, using only Command Line Tools (from apple developer center).
Apple Command Line Tools install the compiler and adds standard libraries and headers to the system in a package much smaller than xcode (which is several GBs).
Running mex on linux is possible - I see no reason why matlab mex should require the huge SDKs for macos. A long evening of trial and error and hacking configuration files hasn't helped. Does anyone have a minimal working example of how to compile a mex file outside matlab, or a simple way to use mex without having xcode installed?
Best Regards, Magnus

  1 Comment

Martin Andersen
Martin Andersen on 20 Sep 2018
I figured out a way around it. Open a terminal window and run the following command:
/usr/libexec/PlistBuddy -c 'Add :IDEXcodeVersionForAgreedToGMLicense string 10.0' ~/Library/Preferences/
This creates a property file with an Xcode version number (the value of which probably doesn't matter). You should now be able to use Command Line Tools without installing Xcode.

Sign in to comment.

Answers (1)

Magnus on 17 Oct 2016


Pierre on 27 Sep 2018
The solution above by Martin Andersen is the fastest and more elegant. I confirm it works perfectly.
Art on 15 Jan 2019
I also had success using the plist trick.

Sign in to comment.

Translated by