Apple Silicon

Please let us know if someone is going to get an Apple computer with the new CPU, and likes to build and test NGSolve on it.


Hi Joachim,

I recently got one of the new computers and I’ll take a stab at this. I’ll follow along with the instructions here.

I will post back with updates.



Python was support was not a core requirement right now, I wanted it to compile so I turned it off with

cmake -DUSE_PYTHON=OFF $NGROOT/ngsolve-src

to focus on just the c++ version.

the cmake command now works without crashing. The same can’t me said about make:

-- Found Git: /usr/bin/git (found version "2.24.3 (Apple Git-128)")
[  0%] Built target ng_generate_version_file
[  1%] Building CXX object libsrc/core/CMakeFiles/ngcore.dir/archive.cpp.o
clang: error: the clang compiler does not support '-march=native'
make[8]: *** [libsrc/core/CMakeFiles/ngcore.dir/archive.cpp.o] Error 1
make[7]: *** [libsrc/core/CMakeFiles/ngcore.dir/all] Error 2
make[6]: *** [all] Error 2
make[5]: *** [dependencies/src/netgen-stamp/netgen-build] Error 2
make[4]: *** [CMakeFiles/netgen.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [dependencies/Stamp/netgen_project/netgen_project-build] Error 2
make[1]: *** [CMakeFiles/netgen_project.dir/all] Error 2
make: *** [all] Error 2

I don’t know what to replace ‘-march=native’ with.


Having problems with the “cmake $NGROOT/ngsolve-src”

CMake Error at /usr/local/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message): Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is at least version "3") Call Stack (most recent call first): /usr/local/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:577 (_FPHSA_FAILURE_MESSAGE) /usr/local/share/cmake-3.19/Modules/FindPythonLibs.cmake:310 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) cmake/SuperBuild.cmake:54 (find_package) CMakeLists.txt:73 (include)

The python headers (PythonLibs) are usually handled by installing python through Homebrew (mac’s 3rd party package manager), but Homebrew is not yet available been updated to the new architecture (and it might take a while).

I am going to see how homebrew usually installs those headers and see if I can do it manually.

That, or if anyone has ideas I am open to them.

Hi Alex,

thank you very much for testing.

Can you install Python (I would try version 3.9 first) natively from ?

To avoid the ‘-march=native’ problem, you can call cmake with
(or just remove it from CMakeLists.txt).


Hi Joachim,

I tried just c++ again with that flag since it would be quick. It threw out a large number of errors and then stopped compiling. I have attached the output for the cmake and make commands.

I will try installing python and see if I can get that part running.


Attachment: output_2020-11-23.txt

can you replace the files in netgen/libsrc/core by these two files and try again:

  1. replace rdtsc intrinsic by __builtin_readcyclecounter()
  2. remove _mm_pause (not necessary, only optimization)

I found it from here:


Attachment: utils.hpp

Attachment: taskmanager.cpp

The latest git version is now supporting the Apple M1 device!

NGSolve can be compiled with the following steps:

Run the following code to download/build/install NGSolve

git clone
cd ngsolve
git submodule update --init --recursive
mkdir build
cd build
/Applications/ ..
make -j5 install

Currently the linker issues a lot of warnings about different visibilities, we are about to fix this.

As usual, set some environment variables to use NGSolve from the command line. Put these lines in the .bash_profile file in your home directory:

export PATH=/Applications/$PATH
export PYTHONPATH=/Applications/$PYTHONPATH

Any feedback is welcome :slight_smile:


I have had time to get back to this. The currently prebuilt .dmg is currently built for python3.8, but I am using python3.9 so instead I am trying to build from source.

I have cloned the ngsolve repo into /Users/alex/Documents/GitHub/ngsolve/ngsolve-source, and then am running the following code, one line at a time.

I get the following error “ld: in ‘/opt/homebrew/opt/llvm/lib/libunwind.dylib’, building for macOS-x86_64 but attempting to link with file built for macOS-arm64” in “/Users/alex/Documents/GitHub/ngsolve/ngsolve-build/netgen/dependencies/src/project_tkdnd-stamp/project_tkdnd-build-err.log”.

I have tried it without the “-DUSE_NATIVE_ARCH=ON”, same issue.

Any help on what I should do to fix this?

[code]export NGROOT=/Users/alex/Documents/GitHub/ngsolve
mkdir $NGROOT/ngsolve-build

cd $NGROOT/ngsolve-build
cmake NGROOT/ngsolve-src -DPYTHON_INCLUDE_DIR=(python3 -c “from distutils.sysconfig import get_python_inc; print(get_python_inc())”) -DPYTHON_LIBRARY=$(python3 -c “import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var(‘LIBDIR’)+‘/libpython3.9.dylib’)”) -DUSE_NATIVE_ARCH=ON

make -j 8

make install

export PYTHONPATH=$PYTHONPATH:/Applications/
export NETGENDIR=/Applications/
export PATH=$NETGENDIR:$PATH[/code]

Hi Alex,

could you attach ngsolve-buid/netgen/CMakeCache.txt ?
I suspect that you are mixing compilers here for some reason ("ld: in ‘/opt/homebrew/opt/llvm/lib/libunwind.dylib’, why not using the system toolchain?)


Hi Matthias,

I am not sure why it used ld form /opt/homebrew. If I run which ld I get /usr/bin/ld

I have attached CMakeCache.txt.


Attachment: CMakeCache.txt

Hi Matthias,

Did the CMakeCache.txt provide any info?