TUTORIAL: Compile DCMTK for Apple Silicon (M1)

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
latinusveridas
Posts: 1
Joined: Mon, 2022-01-03, 16:08

TUTORIAL: Compile DCMTK for Apple Silicon (M1)

#1 Post by latinusveridas »

Hi everyone,
Please find below a quick tutorial to help you compile DCMTK for Apple Silicon.

Tested on Apple Macbook Air A2337

The compilation issues are coming from the SSE librairies, which are specific to x86 arch. Luckily, there is a lib "SSE2NEON" that works.

STEP 1, Download required data
git clone https://github.com/DCMTK/dcmtk
git clone https://github.com/DLTcollab/sse2neon

STEP 2, Download from Homebrew or compile "zlib"

STEP 3 Inject the SSE2Neon lib into the DCMTK source folder
go into the folder DCMTK >> config >> tests
Copy paste sse2neon.h to DCTMK >> config >> include >> dcmtk >> config (on the side of osconfig.h.in)

STEP 4 Shunt the controls
Open arith.cc in order to shunt some controls
change

Code: Select all

#ifdef __APPLE__
// For controlling floating point exceptions on OS X.
#include <xmmintrin.h>
#endif
to

Code: Select all

#ifdef __APPLE__
// For controlling floating point exceptions on OS X.
#include "../include/dcmtk/config/sse2neon.h"
#endif
THEN

comment line 348 by adding double slash at the beginning on the lines "//"

Code: Select all

_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID);
comment line 390

Code: Select all

_MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() | _MM_MASK_INVALID);

STEP 5: Fix libiconv ( including libcharset)
On XCode, Go to Build Settings and search for “Other Linker Flags”
add “-lcharset.1” and “-lliconv.2”
Explanation: The corresponding dylib libs are already included in Xcode Content Package, so you don’t have to “copy the libs (.a or .dylib) in the project files. We just have to indicate which libs we have to link.

ADDITIONAL STEP 6: If you have an error “No data dictionary loaded”
It’s an issue related to the absence of the dicom.dic file in the expected default location, which is normally
/usr/local/share/dcmtk/dicom.dic
So just copy paste the dicom.dic from your downloaded folder to the folder mentioned above. Don’t be afraid to create the directory if not exist.

Cheers,
Latinus

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1435
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: TUTORIAL: Compile DCMTK for Apple Silicon (M1)

#2 Post by Marco Eichelberg »

As a brief follow-up, the current development version of DCMTK available from our git repository compiles and runs on MacOS ARM "out of the box", without any modifications.
We have meanwhile integrated an M1 MacMini into our nightly build infrastructure to make sure it stays that way :wink:

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest