# Developing for Slicer on Apple Silicon (build targeting x86\_64)

**URL:** <https://discourse.slicer.org/t/developing-for-slicer-on-apple-silicon-build-targeting-x86-64/40686>\
**Category:** Development\
**Tags:** build\
**Created:** [December 13, 2024, 10:44pm UTC](https://discourse.slicer.org/t/developing-for-slicer-on-apple-silicon-build-targeting-x86-64/40686 "2024-12-13T22:44:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![arhowe00](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/arhowe00/32/80367_2.png) [@arhowe00](https://discourse.slicer.org/u/arhowe00)\
**Post date:** [December 13, 2024, 10:44pm UTC](https://discourse.slicer.org/t/developing-for-slicer-on-apple-silicon-build-targeting-x86-64/40686/1 "2024-12-13T22:44:12Z")

</div>

The [developer docs](https://slicer.readthedocs.io/en/latest/developer_guide/build_instructions/macos.html) may need a minor update addressing development on the newer Macs (M-series chips). Here is a sufficient-for-development build from source on arm64 MacOS without requiring niche workarounds for specific libraries. The following steps explain how to build Slicer from source on M-chip computers. Note that the Slicer build still targets x86\_64 (i.e. run through Rosetta 2), but native arm64 builds may be rolled out at a future date. To summarize the steps:

1. Install Qt5 with x86\_64 `brew`
2. Use x86\_64 `bash` to build Slicer
3. Turn off SimpleITK
4. There were a few libraries which could not compile using later versions of clang. This discussion post is coupled with [PR#8097](https://github.com/Slicer/Slicer/pull/8097), which cherry picks a few patches in files within [libarchive](https://github.com/libarchive/libarchive).

This is an attempt to partially address [#6811](https://github.com/Slicer/Slicer/issues/6811).

## Step-by-step:

1. Install the latest Xcode SDKs:

2. Checkout Slicer source files

3. Setup the development environment

4. Install x86\_64 Homebrew. You can install “x86\_64 Homebrew” if you run the shell with Rosetta 2:

5. Launch `/bin/bash` with Rosetta 2. x86\_64 Homebrew is in `/usr/local/bin/brew`, and it installs binaries in `/usr/local/bin`. `/usr/local/bin` is added to `PATH` by default on MacOS, so all binaries are accessible without any custom profiles (e.g. `.bash_profile`, `.bashrc`). **You should remain in the x86\_64 `/bin/bash` for the rest of the build.**

6. Configure and build Slicer (from x86\_64 `/bin/bash`). Note that arm64 `cmake` here is permissible:

## Happy developing!

Not all the tests pass, but you should be able to launch Slicer with `./Slicer-Debug/Slicer-build/Slicer`. This should make it easier to develop and iterate over 3DSlicer on Apple Silicon devices. Thank you to @Jared_Vicory for helpful input and @jcfr for the invaluable support.

---

<div class="post-metadata">

**Author:** ![arhowe00](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/arhowe00/32/80367_2.png) [@arhowe00](https://discourse.slicer.org/u/arhowe00)\
**Post date:** [June 9, 2025, 12:21am UTC](https://discourse.slicer.org/t/developing-for-slicer-on-apple-silicon-build-targeting-x86-64/40686/3 "2025-06-09T00:21:50Z")

</div>

It appears that this build guide no longer works with the latest Xcode SDKs.

Instead, a downgrade is required due to the latest macOS SDK versions deprecating or excluding `fp.h`, among other things, in newer releases. Build issues were seen when installing VTK dependencies. I did not try bumping the VTK version used by Slicer or see whether later versions of VTK bump the VTK dependencies to versions that might fix build issues.

I have found that for Slicer v5.8.1 (11eaf62), downgrading the macOS SDK to 15.1, which is released with Xcode 16.1, I was able to build Slicer. To do this:

1. Download [Xcode 16.1](https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_16.1/Xcode_16.1.xip) from [xcodereleases.com](http://xcodereleases.com).
2. Extract `Xcode_16.1.xip` and move it to `/Applications`.

> Note: This extracts to `/Downloads/Xcode.app`, but you should rename it to `Xcode_16.1.app`, as you will likely have multiple installations of `Xcode` on your system.

3. Follow all steps from the guide above, except replace the configuration step with the following:

```sh
cmake \
  -DQt5_DIR:PATH=/usr/local/opt/qt@5/lib/cmake/Qt5 \
  -DCMAKE_OSX_ARCHITECTURES:STRING=x86_64 \
  -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=13.0 \
  -DCMAKE_OSX_SYSROOT:PATH=/Applications/Xcode_16.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk \
  -DCMAKE_BUILD_TYPE:STRING=$cmake_build_type \
  -DSlicer_USE_SYSTEM_QT:BOOL=ON \
  -DSlicer_USE_SimpleITK:BOOL=OFF \
  -B ./Slicer-$cmake_build_type \
  -S ./Slicer

```

4. Follow all steps from above as usual.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [June 9, 2025, 12:32am UTC](https://discourse.slicer.org/t/developing-for-slicer-on-apple-silicon-build-targeting-x86-64/40686/4 "2025-06-09T00:32:51Z")

</div>

> [@arhowe00](#):
>
> I did not try bumping the VTK version used by Slicer or see whether later versions of VTK bump the VTK dependencies to versions that might fix build issues.

@arhowe00 I think this very well may fix the build issues. See for example the following thread with Xcode 16.3 where a specific build fix was included in VTK 9.4. Slicer 5.8.1 was based on a VTK 9.2 version while latest Slicer Preview is based on VTK 9.4, so I would definitely try building latest Slicer Preview with a newer Xcode.

> **[Compile error building VTK-9.3.0.rc1 on MacOS sequoia](https://discourse.vtk.org/t/compile-error-building-vtk-9-3-0-rc1-on-macos-sequoia/15528)**
>
> Building VTK-9.3.0.rc1 on MacOS Sequoia, running xcode Version 16.3 (16E140). Following compile error occurs: \[1%\] Building C object ThirdParty/zlib/vtkzlib/CMakeFiles/zlib.dir/zutil.c.o cd...

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [June 9, 2025, 12:38am UTC](https://discourse.slicer.org/t/developing-for-slicer-on-apple-silicon-build-targeting-x86-64/40686/5 "2025-06-09T00:38:41Z")

</div>

@arhowe00 You may also find helpful the instructions I added to the qt-easy-build project regarding building Slicer (x86\_64) on Apple Silicon. I successfully built Qt 5.15.16 from source on an Apple silicon machine using the macOS 15.2 SDK. Building Qt from source allowed me to build a macOS package for distribution.

> **[GitHub - jcfr/qt-easy-build at 5.15.16](https://github.com/jcfr/qt-easy-build/tree/5.15.16?tab=readme-ov-file#build-for-x86_64-on-apple-silicon-arm64)**
>
> 5.15.16

With this branch I added patches for clang 16 compatibility, but I haven’t checked the status of things if using clang 17 which was released in Xcode 16.3. It is unclear why Apple bumped clang in a minor release of Xcode this time around.

---

<div class="post-metadata">

**Author:** ![arhowe00](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/arhowe00/32/80367_2.png) [@arhowe00](https://discourse.slicer.org/u/arhowe00)\
**Post date:** [June 9, 2025, 3:28am UTC](https://discourse.slicer.org/t/developing-for-slicer-on-apple-silicon-build-targeting-x86-64/40686/6 "2025-06-09T03:28:45Z")

</div>

This is really helpful @jamesobutler , kudos!

---

<div class="post-metadata">

**Author:** ![arhowe00](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/arhowe00/32/80367_2.png) [@arhowe00](https://discourse.slicer.org/u/arhowe00)\
**Post date:** [June 9, 2025, 3:31am UTC](https://discourse.slicer.org/t/developing-for-slicer-on-apple-silicon-build-targeting-x86-64/40686/7 "2025-06-09T03:31:09Z")

</div>

The fix in this reply is only needed if trying to build Slicer v5.8.1. If you need to build Slicer v5.8.1 or older and are having trouble using the macOS SDKs \>15.2, Xcode \>16.3, see the comment above.
