New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiling mex on M1 Mac #130
Comments
Compiling gptoolbox for M1 Mac with Matlab R2022b beta (native apple silicon support):I tried compiling gptoolbox/mex for Matlab beta (as it is faster than rosetta version). Unfortunately, this is not working out of the box. Here the steps i followed
|
cool. Thanks for trying this. I haven't tried the beta matlab silicon version yet. what errors are you running into? |
the main errors basically are that findMATLAB does not support the matlab silicon version, this includes:
additionally i had an issue with the cmake build system: |
Oh I see. So it's working with your changes?
…On Thu, Jan 5, 2023, 3:57 PM paul0noah ***@***.***> wrote:
the main errors basically are that findMATLAB does not support, this
includes:
- matlab bin prefix can not be identified (fixed with step 1)
- matlab mex extension not supported (fixed with
-DMatlab_MEX_EXTENSION="mexmaca64")
- matlab R2022b version not supported (fixed with
-DMATLAB_ADDITIONAL_VERSIONS="R2022b=9.13")
additionally i had an issue with the cmake build system:
my clang compiler did not support -march=native (for fix i upgraded clang)
<https://stackoverflow.com/questions/65966969/why-does-march-native-not-work-on-apple-m1>
—
Reply to this email directly, view it on GitHub
<#130 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARDJGOAI6FELNFUVZMSN63WQ4YUFANCNFSM5PI4ST6A>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Yes, sorry that my post did not make this clear enough. |
Great! Want to submit a PR ? Then I can just make sure it's still working elsewhere. |
Hi. I am attempting to compile the gptoolbox Mex with Matlab 2023b (Arm Version) on an Apple M3 MacBook Pro. I have added "R2023b=23.2" to the MATLAB_VERSIONS_MAPPING in FindMATLAB.cmake. If I run cmake .. -DMatlab_ROOT_DIR="/Applications/MATLAB_R2023b.app/" -DMatlab_MEX_EXTENSION="mexmaca64" -DMATLAB_ADDITIONAL_VERSIONS="R2023b=23.2" I get CMake Error at /Applications/CMake.app/Contents/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message): If I manually specify the paths with cmake .. -DMatlab_ROOT_DIR="/Applications/MATLAB_R2023b.app/" -DMatlab_MEX_EXTENSION="mexmaca64" -DMATLAB_ADDITIONAL_VERSIONS="R2023b=23.2.0" -DMatlab_MEX_LIBRARY="/Applications/MATLAB_R2023b.app/bin/maca64/libmex.dylib" -DMatlab_MEX_COMPILER="/Applications/MATLAB_R2023b.app/bin/maca64/mex" -DMatlab_MX_LIBRARY="/Applications/MATLAB_R2023b.app/bin/maca64/libmx.dylib" -DMatlab_ENG_LIBRARY="/Applications/MATLAB_R2023b.app/bin/maca64/libeng.dylib" Things seems to work in that I get -- Found Matlab: /Applications/MATLAB_R2023b.app/extern/include (found version "23.2") found components: MEX_COMPILER MX_LIBRARY ENG_LIBRARY Boost is fetched etc. But a CMake error occurs -- Creating target: igl_restricted::matlab (igl_restricted_matlab) I am a little lost as to how to fix this issue. |
Hi @scarfelab, I did some debugging in the the findMATLAB.cmake file shipped with gptoolbox and found that For me this command worked, i.e. adding
I hope this helps Paul |
Thanks. This is admittedly still a mess as cmake's findmatlab tries to
catch up. Hopefully resolved soon and I don't need to maintain this
findmatlab.cmake
…On Mon, Nov 20, 2023 at 2:10 PM paul0noah ***@***.***> wrote:
Hi @scarfelab <https://github.com/scarfelab>,
I did some debugging in the the findMATLAB.cmake file shiped with
gptoolbox and found that CMAKE_OSX_ARCHITECTURES was unset which caused
that the findMATLAB script was searching inside
/Applications/MATLAB_R2023b.app/bin/maci64 instead of
/Applications/MATLAB_R2023b.app/bin/maca64 folder.
For me this command worked, i.e. adding -DCMAKE_OSX_ARCHITECTURES="arm64"
to your cmake call:
cmake .. -DMatlab_ROOT_DIR="/Applications/MATLAB_R2023b.app/"
-DMatlab_MEX_EXTENSION="mexmaca64"
-DMATLAB_ADDITIONAL_VERSIONS="R2023b=23.2" -DCMAKE_OSX_ARCHITECTURES="arm64"
I hope this helps
Paul
—
Reply to this email directly, view it on GitHub
<#130 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARDJGPTIG3H42GI2W62S33YFOTJBAVCNFSM5PI4ST6KU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBRHE3DIOBRG43Q>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@paul0noah Many thanks for your help. Really appreciated. I am not very familiar with cmake, hence my difficulties. Following your instructions has worked much better, but I still get an error. [ 45%] Performing configure step for 'gmp' I have checked in the "_deps" folder created by cmake and I can see a gmp folder with various files in, suggesting that it has downloaded. However, I notice that unlike most of the others, there is not "-build" "-src" and "-subbuild" variants. See attached screenshot. The same is also true of mpfr. I notice that the instructions suggest I might need to install boost, mpfr and gmp. However, boost seems to have been dowloaded ok as has a "-build" "cmake-build" "-src" and "-subbuild" pattern similar to the other downloads. Many thanks again for your help. It is really appreciated. Peter |
Hi Peter, the folder strucutre looks similar on my machine and I also encounter compile errors with gmp stuff and I think @alecjacobson himself has to have a look at this. Workaround to get parts of mex files built: Since i never needed these parts of gptoolbox my "workaround" was to compile with Best |
@paul0noah Awesome. Thanks again Paul. This has indeed worked for me i.e. goes through everything building when it can. I really will have to get more familiar with cmake. Glad I was not doing anything wrong r.e. the issue I had with gmp mpfr. Visually it looks like a fair number of the Mex files cannot be built. However, for me at the moment the key things were related to Embree, which seems to have been built ok. Though I still need to have a more extensive play. @alecjacobson happy to test any modified version if it would be of any help. Thank-you both again for your help. Really appreciated it. |
Hi both @alecjacobson @paul0noah It turned out some of the crucial mex files I needed were not built. Sigh... However, I have made a little more progress, all be it of dubious nature. I installed gmp and mpfr in the default /usr/local/ location. Installation and check went fine. I then re-ran
Turns out this does not seem to locate either gmp or mpfr in /usr/local/. However, the Thus, something appears to have changed in terms of cmake being able to find online what it needs in terms of gmp and mpfr. Indeed, I can completely remove my installed versions in /usr/local/ and things work just as well. So, progress, but no thanks to my own efforts. |
Matlab currently runs on M1 Macs as using Rosetta https://www.mathworks.com/matlabcentral/answers/641925-is-matlab-supported-on-apple-silicon-macs
Unfortunately, this means that building the mex files as a native arm64 binaries will not work. :-(
Fortunately, it's not too hard to build the mex functions using rosetta. This requires a (still in PR) version of libigl which builds gmp and mpfr from source (rather than relying a system install from, say, homebrew which would just include arm64 binaries).
The upshot is that as of 36df062 you can build mex on m1 macs using rosetta with:
This hasn't yet been documented in the mex/README.md
The text was updated successfully, but these errors were encountered: