Mac Mojave(10.14.1)执行Matlab的mex报错

先装了matlab2018b,发现很频繁的crash,同时考虑到要跑的代码在>=2017a时就计算错误,于是转战matlab2016b

matlab2016b安装后,执行mex -setup报错:

>> mex -setup
find: 37589: No such file or directory
find: 37592: No such file or directory
find: 37595: No such file or directory

尝试了matlab2015b,发现mex依然报错,通过修改/path/to/matlab/bin/mexopts.sh中macos的sdk版本,以及clang_maci64.xml中macos sdk版本,然后解决的问题。

https://blog.csdn.net/bingshanqiao/article/details/48948065?utm_source=blogxgwz6 -修改mexopts.sh

https://blog.csdn.net/sinat_38068956/article/details/80326877 -修改clang_maci64.xml

=====

顺带做了mex混编,发现-fopenmp参数传进去无法被识别。

⚡ brew install libomp
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/cask-versions, homebrew/core and homebrew/cask).
==> New Formulae
chafa           libgusb         libvirt-glib    needle          spice-protocol
cryptominisat   libpulsar       lsd             simple-scan
==> Updated Formulae
fltk ✔          eccodes         getdns          minio           pdftoipe
allure          exploitdb       glances         minio-mc        poppler
amqp-cpp        eye-d3          goreleaser      mongodb         pre-commit
ark             fluid-synth     gradle          ngspice         youtube-dl
clamav          frugal          knot            paket
diff-pdf        fuseki          knot-resolver   pdftoedn

==> Downloading https://homebrew.bintray.com/bottles/libomp-7.0.0.mojave.bottle.
######################################################################## 100.0%
==> Pouring libomp-7.0.0.mojave.bottle.tar.gz
==> Caveats
On Apple Clang, you need to add several options to use OpenMP's front end
instead of the standard driver option. This usually looks like
  -Xpreprocessor -fopenmp -lomp

You might need to make sure the lib and include directories are discoverable
if /usr/local is not searched:

  -L/usr/local/opt/libomp/lib -I/usr/local/opt/libomp/include

For CMake, the following flags will cause the OpenMP::OpenMP_CXX target to
be set up correctly:
  -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" -DOpenMP_CXX_LIB_NAMES="omp" -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib
原文地址:https://www.cnblogs.com/zjutzz/p/10258155.html