Compilation of SPM on macOS¶
This page describes the compilation of SPM MEX files on macOS.
Tip
If you are using macOS Catalina, Big Sur, Monterey, Ventura or Sonoma and have apparent problems with the MEX files provided with SPM, check the Troubleshooting section first as it is very likely you do not need to recompile the MEX files.
To compile SPM MEX files, you need to have Apple’s development environment Xcode installed.
You also need to have the mex
executable in your system path. To do
so, type the following in a Terminal:
If you get errors such as Bad : modifier in $ (/)
, this is because
the instructions are given for a bash
Terminal while you are using a
tcsh
Terminal. The equivalent commands are:
An alternative is to use the MEXBIN
environment variable when invoking make
:
Instructions¶
In a Terminal, from the src folder of your SPM installation, type:
cd /Users/login/spm/src
make distclean
make && make install
make external-distclean
make external && make external-install
This will generate *.mexmaci64
MEX files. To generate *.mexmaca64
MEX files, add PLATFORM=arm64
to the commands above.
Troubleshooting¶
macOS Catalina, Big Sur, Monterey, Ventura, Sonoma
If you have issues with MEX files on macOS with one of these errors:
"*.mexmaci64" cannot be opened because the developer cannot be verified.
macOS cannot verify that this app is free from malware
Code signature not valid for use in process using Library Validation: library load disallowed by system policy
cd
to the SPM directory and type:
If it doesn’t work, please try this equivalent alternative, replacing SPM_PATH
with the path of your SPM installation:
sudo xattr -r -d com.apple.quarantine SPM_PATH
sudo find SPM_PATH -name "*.mexmaci64" -exec spctl --add {} \;
If you are using Apple Silicon (ARM), make sure to edit the command lines so that it targets .mexmaca64
files.
xcrun: error: SDK "macosx10.14.1" cannot be located
error
If you get errors such as xcrun: error: SDK "macosx10.14.1" cannot be located
while compiling, execute the following before compilation:
Java Exception and abrupt exit on Mac OS X version 10.10 Yosemite
If you get MATLAB issues with Yosemite, see the following bug report for a patch:
This is pdfTeX, Version ...
error
If you get an error message such as:
mex -O -c spm_vol_utils.c -DSPM_UNSIGNED_CHAR
mex: unrecognized option `-O'
mex: unrecognized option `-c'
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
restricted \write18 enabled.
entering extended mode
(./spm_vol_utils.c
This is MeX Version 1.05 18 XII 1993 (B. Jackowski & M. Ry\'cko)
! You can't use `macro parameter character #' in vertical mode.
mex
and a LaTeX command with
the same name. Edit src/Makefile.var
and mention the full path when
referring to MEXBIN
or change PATH accordingly.