# Compile failure on Mac OSX M1 arm64

**URL:** https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342
**Category:** Google Groups archive
**Created:** [February 27, 2021, 5:26pm UTC](https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342 "2021-02-27T17:26:04Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![John\_Murray1](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@John\_Murray1](https://discourse.orthanc-server.org/u/John_Murray1)
#### Post date: [February 27, 2021, 5:26pm UTC](https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342/1 "2021-02-27T17:26:04Z")

</div>

Has anyone successfully compiled the server on an M1 Laptop for an M1 laptop?

When I run the cmake command on an M1 laptop:

cmake -GXcode -DCMAKE\_OSX\_DEPLOYMENT\_TARGET=10.9 -DSTATIC\_BUILD=ON -DSTANDALONE\_BUILD=ON -DALLOW\_DOWNLOADS=ON …/OrthancServer

OR

cmake -GXcode -DCMAKE\_OSX\_DEPLOYMENT\_TARGET=11.0 -DSTATIC\_BUILD=ON -DSTANDALONE\_BUILD=ON -DALLOW\_DOWNLOADS=ON …/OrthancServer

I get an error that seems like Xcode is running a test for a webassembly target on an x86

Here is one of the errors that I get:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -target arm64-apple-macos10.9 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -DCMAKE\_INTDIR="Release" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -I/Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/CMakeTmp/Arith/CMakeFiles/CMakeTmp/Release/include -I/Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/CMakeTmp/Arith/CMakeFiles/CMakeTmp/CMAKE\_TRY\_COMPILE.build/Release/cmTC\_1c6c0.build/DerivedSources-normal/arm64 -I/Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/CMakeTmp/Arith/CMakeFiles/CMakeTmp/CMAKE\_TRY\_COMPILE.build/Release/cmTC\_1c6c0.build/DerivedSources/arm64 -I/Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/CMakeTmp/Arith/CMakeFiles/CMakeTmp/CMAKE\_TRY\_COMPILE.build/Release/cmTC\_1c6c0.build/DerivedSources -F/Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/CMakeTmp/Arith/CMakeFiles/CMakeTmp/Release -I/Users/jmurray/code/orthanc/Build/dcmtk-3.6.6//config/include -I/Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/ofstd/include -I/Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/ofstd/libsrc -MMD -MT dependencies -MF /Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/CMakeTmp/Arith/CMakeFiles/CMakeTmp/CMAKE\_TRY\_COMPILE.build/Release/cmTC\_1c6c0.build/Objects-normal/arm64/arith.d --serialize-diagnostics /Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/CMakeTmp/Arith/CMakeFiles/CMakeTmp/CMAKE\_TRY\_COMPILE.build/Release/cmTC\_1c6c0.build/Objects-normal/arm64/arith.dia -c /Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/config/tests/arith.cc -o /Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/CMakeTmp/Arith/CMakeFiles/CMakeTmp/CMAKE\_TRY\_COMPILE.build/Release/cmTC\_1c6c0.build/Objects-normal/arm64/arith.o

In file included from  
/Users/jmurray/code/orthanc/Build/dcmtk-3.6.6/config/tests/arith.cc:45:

In file included from  
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/xmmintrin.h:13:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include/mmintrin.h:33:5:  
error: use of undeclared identifier ‘\_\_builtin\_ia32\_emms’; did you mean  
‘\_\_builtin\_isless’?

\_\_builtin\_ia32\_emms();

---

<div class="post-metadata">

### Author: ![bdearlove](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/bdearlove/32/1661_2.png) [@bdearlove](https://discourse.orthanc-server.org/u/bdearlove)
#### Post date: [February 27, 2021, 6:37pm UTC](https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342/2 "2021-02-27T18:37:23Z")

</div>

I just downloaded the compiled one from Osimis and it works no problem.

---

<div class="post-metadata">

### Author: ![John\_Murray1](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@John\_Murray1](https://discourse.orthanc-server.org/u/John_Murray1)
#### Post date: [February 27, 2021, 7:33pm UTC](https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342/3 "2021-02-27T19:33:28Z")

</div>

Thank you, Bryan! I tried to load the binary image, but I did not understand how the command file worked. After about 10 overrides of non-Apple Store files, I got the binary version of the server to work. Thank you!!!

I am curious to know if there is some special command to compile the code on an M1 or if it was cross-compiled from an x86 mac.

thank you!

john

---

<div class="post-metadata">

### Author: ![jodogne](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/jodogne/32/1511_2.png) [@jodogne](https://discourse.orthanc-server.org/u/jodogne)
#### Post date: [February 28, 2021, 9:37am UTC](https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342/4 "2021-02-28T09:37:31Z")

</div>

Hello,

This compilation error means that either DCMTK doesn’t support M1 (unlikely), _or_ that the following files must be adapted in the source code of Orthanc (more probable):  
[https://hg.orthanc-server.com/orthanc/file/default/OrthancFramework/Resources/CMake/DcmtkConfiguration.cmake](https://hg.orthanc-server.com/orthanc/file/default/OrthancFramework/Resources/CMake/DcmtkConfiguration.cmake)

[https://hg.orthanc-server.com/orthanc/file/default/OrthancFramework/Resources/CMake/DcmtkConfigurationStatic-3.6.6.cmake](https://hg.orthanc-server.com/orthanc/file/default/OrthancFramework/Resources/CMake/DcmtkConfigurationStatic-3.6.6.cmake)

Similar compilation errors have been reported for other software, for instance:  
[https://github.com/emscripten-core/emscripten-fastcomp-clang/issues/29](https://github.com/emscripten-core/emscripten-fastcomp-clang/issues/29)

Unfortunately, I don’t have access to such an Apple computer, so I can’t provide any fix by myself.

To answer the second part of your question, the Osimis binary package is built on a x86 MacMini from 2014. Full info:

$ system\_profiler SPSoftwareDataType  
Software:

System Software Overview:

System Version: OS X 10.9.5 (13F1911)  
Kernel Version: Darwin 13.4.0

Sébastien-

---

<div class="post-metadata">

### Author: ![James\_Manners](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/j/a9adbd/32.png) [@James\_Manners](https://discourse.orthanc-server.org/u/James_Manners)
#### Post date: [February 28, 2021, 9:55am UTC](https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342/5 "2021-02-28T09:55:04Z")

</div>

I have an M1 Mac so can help to troubleshoot. I did try to install dmctk using home brew a week or so back and it didn’t compile either.

Are there any pointers you can give so I can look into it?

James

[![Binary Logo](https://binary.com.au/assets/e-binary.png)](https://binary.com.au/)

**James Manners** • Director  
Suite 3, Level 2, 10 Queens Road, Melbourne, Victoria 3004, Australia

T: 03 9017 5230 M: 0422 973 235 E: [james@binary.com.au](mailto:james@binary.com.au) W: [binary.com.au](https://binary.com.au/)

---

<div class="post-metadata">

### Author: ![jodogne](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/jodogne/32/1511_2.png) [@jodogne](https://discourse.orthanc-server.org/u/jodogne)
#### Post date: [February 28, 2021, 1:17pm UTC](https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342/6 "2021-02-28T13:17:46Z")

</div>

Hello James,

Thanks for your feedback! The first thing to try would indeed be to compile DCMTK 3.6.6 from source (using CMake) on M1 Mac, without even considering Orthanc.

If the compilation doesn’t succeed, this should be reported to the DCMTK team:  
[https://forum.dcmtk.org/](https://forum.dcmtk.org/)

Sébastien-

---

<div class="post-metadata">

### Author: ![James\_Manners](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/j/a9adbd/32.png) [@James\_Manners](https://discourse.orthanc-server.org/u/James_Manners)
#### Post date: [February 28, 2021, 10:44pm UTC](https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342/7 "2021-02-28T22:44:23Z")

</div>

Hi Sebastien,

I had a quick look on the DCMTK Issue Tracker and this issue is open regarding compilation on a Mac M1 (ARM) chip [https://support.dcmtk.org/redmine/issues/957](https://support.dcmtk.org/redmine/issues/957)

So it looks like there are issues with DCMTK compiling on an M1.

HTH

James

---

<div class="post-metadata">

### Author: ![John\_Murray1](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@John\_Murray1](https://discourse.orthanc-server.org/u/John_Murray1)
#### Post date: [March 1, 2021, 1:06am UTC](https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342/8 "2021-03-01T01:06:32Z")

</div>

Thank you to all. I am using the cross-compiled binary. I appreciate the investigation.

We can let this one go for now.

john

---

<div class="post-metadata">

### Author: ![Alain\_Mazy](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/a/9de053/32.png) [@Alain\_Mazy](https://discourse.orthanc-server.org/u/Alain_Mazy)
#### Post date: [March 28, 2022, 9:39pm UTC](https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342/9 "2022-03-28T21:39:54Z")

</div>

Hi,

Here are 2 fixes which seems to solve the Apple M1 build issues:  
[https://hg.orthanc-server.com/orthanc/rev/1b6b88f017b9](https://hg.orthanc-server.com/orthanc/rev/1b6b88f017b9)  
[https://hg.orthanc-server.com/orthanc/rev/3c3bb0181e96](https://hg.orthanc-server.com/orthanc/rev/3c3bb0181e96)

At least, I’ve been able to produce a universal binary on an Intel Mac but I have not been able to run it on a M1 processor (because I don’t have any 🙂 ). Any feedback is welcome.

HTH

Alain.

---

<div class="post-metadata">

### Author: ![salimkanoun](https://discourse.orthanc-server.org/letter_avatar_proxy/v4/letter/s/6de8d8/32.png) [@salimkanoun](https://discourse.orthanc-server.org/u/salimkanoun)
#### Post date: [March 31, 2022, 9:20am UTC](https://discourse.orthanc-server.org/t/compile-failure-on-mac-osx-m1-arm64/2342/10 "2022-03-31T09:20:32Z")

</div>

Just for information,  
In case you need a M1 environement to code / test

You can have a M1 instance for few hours in some cloud providers such as scaleway : [https://www.scaleway.com/en/hello-m1](https://www.scaleway.com/en/hello-m1)

This way no need to pay for overpriced mac products ^^

Salim
