Mex on macosx without xcode

23 visualizaciones (últimos 30 días)
Magnus
Magnus el 14 de Oct. de 2016
Comentada: Christian Busse el 19 de Nov. de 2024 a las 21:49
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
  2 comentarios
Martin Andersen
Martin Andersen el 20 de Sept. de 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/com.apple.dt.Xcode.plist
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.
Alek Pikl
Alek Pikl el 4 de Nov. de 2020
Editada: Alek Pikl el 4 de Nov. de 2020
This fixed it for me.
My problem was running mex on a macbook without having to install the full Xcode.
Running
mex -setup
returned an error somewhat in the lines of xcode licence not accepted .
I installed CL Tools but couldn't accept the licence by using
sudo xcodebuild -license
due to some error that CL Tools are not Xcode...

Iniciar sesión para comentar.

Respuestas (3)

Magnus
Magnus el 17 de Oct. de 2016
  3 comentarios
Art
Art el 15 de En. de 2019
I also had success using the plist trick.
Roy Goodman
Roy Goodman el 24 de Sept. de 2021
@Magnus can you share the XML file that you created in Option 2 of your stackexchange answer? I tried to modify it myself, but didn't know what I was doing and got an error when I tried to run mex.

Iniciar sesión para comentar.


Ian
Ian el 7 de En. de 2022
There is another solution that works with 2021b: https://stackoverflow.com/a/41538477/415013 — I do not have enough space to install XCode and command-line tools can compile mex files so this solution works well! Mathworks should make it easier to use the command-line tools rather than require the massive XCode install...

Christian Busse
Christian Busse el 19 de Nov. de 2024 a las 11:51
The following solution is from https://gist.github.com/martinandersen/1fea529ec04885c63477ccb944394494 but also mentioned in the same stackoverflow thread reference above.
Run the following command in the mac terminal:
defaults write com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense 16.1
Make sure to adjust 16.1 to your actual xcode version, which you can show using:
pkgutil --pkg-info=com.apple.pkg.CLTools_Executables
The defaults write command in macOS is a terminal command used to modify macOS application preferences by writing to the application’s property list (plist) files. Adding that property indicates to MATLAB that the license has been accepted for the specified version.
Now you can verify that the compilers are working in MATLAB by checking the output from:
mex -setup
Also I would run some of the examples from here https://de.mathworks.com/help/releases/R2024b/matlab/ref/mex.html
to test if everything is working.
  2 comentarios
Roy Goodman
Roy Goodman el 19 de Nov. de 2024 a las 12:54
I followed this command and Christian's suggestions to work through the examples. The following line returned an error:
mex -largeArrayDims fulltosparse.F loadsparse.F
Can XCode handle these Fortran files?
Christian Busse
Christian Busse el 19 de Nov. de 2024 a las 21:49
Indeed, the Xcode compilers are only for C and C++. For Fotran, you would need to install a separate compiler. According to MATLAB documentation the NAG Fortran Compiler is verified to work with Mac on Apple Silicon: https://de.mathworks.com/support/requirements/supported-compilers-mac.html

Iniciar sesión para comentar.

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by