How to build on macOS ARM?

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
oursland
Posts: 55
Joined: Sat Mar 11, 2023 9:33 pm

Re: How to build on macOS ARM?

Post by oursland »

@fpetzold, unfortunately I cannot see any obvious issues in those logs that would indicate the cause of this problem. It appears that std::unary_function was deprecated in C++11 and removed from C++17 resulting in the compilation error. I wonder if there's a package version mismatch between your install and mine which is leading to this error.

Attached is my environment as generated from conda env export which indicates precisely which version of each package was installed. I recommend exporting your own environment package list and using diff to identify which, if any, package differences exist.

freecad-env.txt
Conda FreeCAD environment
(10.07 KiB) Downloaded 27 times
fpetzold
Posts: 20
Joined: Tue Mar 28, 2023 1:48 pm

Re: How to build on macOS ARM?

Post by fpetzold »

I did diff on my conda freecad env. There are quite significant differences, an I don't understand how this can happen.

Most notably, libcxx and conda itself differ. Maybe you all can take a look and help me figure this one out...

Is there some source file I can try to change to get the environment exactly as yours? I still have to learn how anaconda works.

13a14
> - boltons=23.0.0=pyhd8ed1ab_0
42c43
< - conda=23.1.0=py311h267d04e_0
---
> - conda=23.3.0=py311h267d04e_0
45c46
< - conda-forge-pinning=2023.03.27.19.48.24=hd8ed1ab_0
---
> - conda-forge-pinning=2023.03.29.08.25.52=hd8ed1ab_0
71c72
< - fonttools=4.39.2=py311he2be06e_0
---
> - fonttools=4.39.3=py311he2be06e_0
130c131
< - libcxx=15.0.7=h75e25f2_0
---
> - libcxx=16.0.0=h75e25f2_0
229c230
< - pyopenssl=23.1.0=pyhd8ed1ab_0
---
> - pyopenssl=23.1.1=pyhd8ed1ab_0
237c238
< - pytz=2023.2=pyhd8ed1ab_0
---
> - pytz=2023.3=pyhd8ed1ab_0
272c273
< - tzdata=2023b=h71feb2d_0
---
> - tzdata=2023c=h71feb2d_0
303,310d303
< - alabaster==0.7.13
< - appdirs==1.4.4
< - babel==2.12.1
< - cattrs==22.2.0
< - docutils==0.19
< - esbonio==0.16.1
< - imagesize==1.4.1
< - lsprotocol==2023.0.0a1
312,324c305
< - pygls==1.0.1
< - pygments==2.14.0
< - pyspellchecker==0.7.1
< - snowballstemmer==2.2.0
< - sphinx==6.1.3
< - sphinxcontrib-applehelp==1.0.4
< - sphinxcontrib-devhelp==1.0.2
< - sphinxcontrib-htmlhelp==2.0.1
< - sphinxcontrib-jsmath==1.0.1
< - sphinxcontrib-qthelp==1.0.3
< - sphinxcontrib-serializinghtml==1.1.5
< - typeguard==2.13.3
< prefix: /Users/jso/code/FreeCAD/FreeCAD/.conda/freecad
---
> prefix: /Users/fpe/compile/FreeCAD/.conda/freecad
fpetzold
Posts: 20
Joined: Tue Mar 28, 2023 1:48 pm

Re: How to build on macOS ARM?

Post by fpetzold »

I was able to compile and run FreeCAD after adding the following to conda/environment.devenv.yml

- libcxx==15.0.7

Next step would be to have the SpaceMouse driver to be used, which it is not. I might try to restrict to libcxx < 16.

Thanks again for all the help!

P.S.:
- libcxx<16

does the trick.

I tried to configure with

Code: Select all

/Users/fpe/compile/FreeCAD/.conda/freecad/bin/cmake --no-warn-unused-cli -DBUILD_WITH_CONDA:BOOL:STRING=ON -DBUILD_FEM_NETGEN:BOOL:STRING=ON -DFREECAD_USE_PYBIND11:BOOL:STRING=ON -DFREECAD_USE_EXTERNAL_SMESH:BOOL:STRING=ON -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_C_COMPILER:FILEPATH=/Users/fpe/compile/FreeCAD/.conda/freecad/bin/clang -DCMAKE_CXX_COMPILER:FILEPATH=/Users/fpe/compile/FreeCAD/.conda/freecad/bin/clang++  -DFREECAD_USE_3DCONNEXION:BOOL=ON -D3DCONNEXIONCLIENT_FRAMEWORK:FILEPATH="/Library/Frameworks/3DconnexionClient.framework"      -S/Users/fpe/compile/FreeCAD -B/Users/fpe/compile/FreeCAD/build -G Ninja
(note the 3DCONNEXION stuff)

and compiled, but still could not get the SpaceMouse to work. How can I verify the driver is really included?

And another question would be as to how to build the actual App for MacOS, sign it using my developer key and package it to a DMG.
User avatar
adrianinsaval
Veteran
Posts: 5534
Joined: Thu Apr 05, 2018 5:15 pm

Re: How to build on macOS ARM?

Post by adrianinsaval »

did you download and install the driver like is done here: https://github.com/looooo/freecad-feeds ... sh#L40-L46 (but using an up to date driver that supports arm)?
fpetzold
Posts: 20
Joined: Tue Mar 28, 2023 1:48 pm

Re: How to build on macOS ARM?

Post by fpetzold »

adrianinsaval wrote: Fri Mar 31, 2023 1:54 pm did you download and install the driver like is done here: https://github.com/looooo/freecad-feeds ... sh#L40-L46 (but using an up to date driver that supports arm)?
Yes, I did. The mouse also seems to be recognized, it shows up in the Tools/Customize... dialog

While this is not the case with the precompiled ARM version from GitHub. So, I am pretty sure all this is well. I just cannot move anything in FreeCAD. Oh, the Connexion demo apps work like a charm of course, so the mouse is working.
JohnOCFII
Posts: 112
Joined: Sun Sep 20, 2020 5:46 pm
Location: Minnesota, USA

Re: How to build on macOS ARM?

Post by JohnOCFII »

fpetzold wrote: Fri Mar 31, 2023 9:15 am I was able to compile and run FreeCAD after adding the following to conda/environment.devenv.yml

- libcxx==15.0.7
Glad you got it working, but curious what differed in your enviroment? In an earlier note, you mentioned using MacPorts instead of Homebrew. Curious if that had an impact?
And another question would be as to how to build the actual App for MacOS, sign it using my developer key and package it to a DMG.
I think the creation of the DMG with installable App is part @loos Conda-build. Not sure how much effort it would be to take on to this set of build instructions, or if there is a better way to integrate that. I know the team has also been challenged in figuring out the best way to sign the app too.

For now, I have followed Irv's instructions to use Automator to create an app that runs a shell script to launch FreeCAD (or I launch it from within VSCode). https://www.makewithtech.com/post/freec ... s-on-macos
oursland
Posts: 55
Joined: Sat Mar 11, 2023 9:33 pm

Re: How to build on macOS ARM?

Post by oursland »

@fpetzold I am glad you got the build working! Getting dependencies right is a real concern.

conda build configuration

When exporting an environment for sharing, it can be done exactly, with each dependency specified precisely. Decades of development experience leads me to believe that this approach results in stagnation, and worse security concerns. The alternative is to let the versions get solved for, as we have now, but set the constraints necessary for a successful build.

I wish I knew exactly what led to the unbuildable configuration. At current the toolchains are selected by the meta project compilers which sets defaults for macOS (Clang 14), Linux (GCC 11), and Windows (VS2019). For libc++ 16 to be installed and used would mean that a later command or package pulled it in.

3Dconnexion Framework

I too have a SpaceMouse (3Dconnexion SpaceTraveler from 2008) that would be nice to have working. I've noticed that the driver from 3Dconnexion is build for the x86_64 platforms. I have not yet attempted to make this device work, however @looo did set up the FreeCAD conda build scripts to download, install, and build against the 3Dconnexion driver. You'll find the steps here: https://github.com/conda-forge/freecad- ... ild.sh#L26

I can confirm that the recently distributed 3DconnexionClient Framework are Mach-O universal binaries with support for both x86_64 and arm64 architectures. The location of this framework is /Library/Frameworks/3DconnexionClient.framework.

Distributable FreeCAD.app packages

I have not yet dug too deep in understanding how the distributable FreeCAD.app packages are built. My original aim was to enable developers to build and debug on recent Apple hardware. Being able to share a binary would be a nice capability, so I will spend some time towards this goal in the near future.
User avatar
chennes
Veteran
Posts: 3868
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: How to build on macOS ARM?

Post by chennes »

oursland wrote: Fri Mar 31, 2023 5:06 pm I too have a SpaceMouse (3Dconnexion SpaceTraveler from 2008) that would be nice to have working.
Just a note that I have SpaceMouse working on my Mac M2, and it required no special machinations other than installing the 3D Connexion software prior to compiling, and turning the appropriate option on in the CMake setup.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
oursland
Posts: 55
Joined: Sat Mar 11, 2023 9:33 pm

Re: How to build on macOS ARM?

Post by oursland »

@fpetzold I have reproduced the error you observed after following the build instructions. It's a result of libcxx version 16 being installed.

The issue is outlined in the GitHub issue here: https://github.com/conda-forge/libcxx-f ... issues/114

There are three resolutions:

1. Pin the package to libcxx<16
2. Define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY in the build flags.
3. Upstream fix to the boost-cpp-feedstock in the following PR: https://github.com/conda-forge/boost-cp ... k/pull/135

I will submit a PR to pin libcxx<16. After the upstream fix to boost-cpp-feedstock is accepted and the other Conda builds in CI return to working order, I'll revert the change.
fpetzold
Posts: 20
Joined: Tue Mar 28, 2023 1:48 pm

Re: How to build on macOS ARM?

Post by fpetzold »

chennes wrote: Fri Mar 31, 2023 5:51 pm
oursland wrote: Fri Mar 31, 2023 5:06 pm I too have a SpaceMouse (3Dconnexion SpaceTraveler from 2008) that would be nice to have working.
Just a note that I have SpaceMouse working on my Mac M2, and it required no special machinations other than installing the 3D Connexion software prior to compiling, and turning the appropriate option on in the CMake setup.
Please tell me what that option is.
Post Reply