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
Code: Select all
#ifdef __APPLE__
// For controlling floating point exceptions on OS X.
#include "../include/dcmtk/config/sse2neon.h"
#endif
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);
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