Error building DCMTK with Apple M1 chip

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
samee
Posts: 17
Joined: Thu, 2023-03-30, 15:27

Error building DCMTK with Apple M1 chip

#1 Post by samee »

Hi there,
I am a maintainer of an open-source feature extraction library for biomedical images that uses dcmtk to read dicom images. Till now, we have been using version 3.6.7 and were successfully able to integrate it to Windows, Linux and Apple Amd64 Python wheels. Now we are looking into creating Apple arm64 Python wheels and ran into an issue with building dcmtk. We tried the latest version (3.6.8 ) also and experienced the same issue. Below is how we are building it and the error we are seeing.

Code: Select all

    curl -L https://github.com/DCMTK/dcmtk/archive/refs/tags/DCMTK-3.6.7.zip -o DCMTK-3.6.7.zip
    unzip DCMTK-3.6.7.zip
    cd dcmtk-DCMTK-3.6.7
    mkdir build_man
    cd build_man
    cmake -DDCMTK_WITH_ICONV=OFF -DBUILD_SHARED_LIBS=ON -DBUILD_APPS=OFF  ..
    make install -j4
    cd ../../
The error we see in the Apple arm64 platform is the following:

Code: Select all

2024-01-29T20:30:34.8552320Z [ 58%] Building CXX object dcmrt/libsrc/CMakeFiles/dcmrt.dir/drtbldts.cc.o
2024-01-29T20:30:34.8592310Z Undefined symbols for architecture arm64:
2024-01-29T20:30:34.8653990Z   "_TIFFCleanup", referenced from:
2024-01-29T20:30:34.8722770Z       DiTIFFPlugin::write(DiImage*, __sFILE*, unsigned long) const in dipitiff.cc.o
2024-01-29T20:30:34.8776820Z   "_TIFFFdOpen", referenced from:
2024-01-29T20:30:34.8821670Z       DiTIFFPlugin::write(DiImage*, __sFILE*, unsigned long) const in dipitiff.cc.o
2024-01-29T20:30:34.8891240Z   "_TIFFFlushData", referenced from:
2024-01-29T20:30:34.8905070Z       DiTIFFPlugin::write(DiImage*, __sFILE*, unsigned long) const in dipitiff.cc.o
2024-01-29T20:30:34.8942490Z   "_TIFFGetVersion", referenced from:
2024-01-29T20:30:34.8963840Z       DiTIFFPlugin::getLibraryVersionString() in dipitiff.cc.o
2024-01-29T20:30:34.8965480Z   "_TIFFSetField", referenced from:
2024-01-29T20:30:34.8966970Z       DiTIFFPlugin::write(DiImage*, __sFILE*, unsigned long) const in dipitiff.cc.o
2024-01-29T20:30:34.8968510Z   "_TIFFWriteScanline", referenced from:
2024-01-29T20:30:34.8969880Z       DiTIFFPlugin::write(DiImage*, __sFILE*, unsigned long) const in dipitiff.cc.o
2024-01-29T20:30:34.8971350Z ld: symbol(s) not found for architecture arm64
2024-01-29T20:30:34.8973270Z clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
2024-01-29T20:30:34.8974920Z make[2]: *** [lib/libdcmimage.17.3.6.7.dylib] Error 1
2024-01-29T20:30:34.8976290Z make[1]: *** [dcmimage/libsrc/CMakeFiles/dcmimage.dir/all] Error 2
We have libtiff v 4.6.0 installed in the build environment and the CMake output from dcmtk configuration seems to find it correctly.

Code: Select all

2024-01-29T20:28:39.4241250Z -- The C compiler identification is Clang 16.0.6
2024-01-29T20:28:39.5387130Z -- The CXX compiler identification is Clang 16.0.6
2024-01-29T20:28:39.5866740Z -- Detecting C compiler ABI info
2024-01-29T20:28:39.7707870Z -- Detecting C compiler ABI info - done
2024-01-29T20:28:39.7755040Z -- Check for working C compiler: /opt/homebrew/opt/llvm@16/bin/clang - skipped
2024-01-29T20:28:39.7757340Z -- Detecting C compile features
2024-01-29T20:28:39.7759560Z -- Detecting C compile features - done
2024-01-29T20:28:39.8054970Z -- Detecting CXX compiler ABI info
2024-01-29T20:28:39.9468090Z -- Detecting CXX compiler ABI info - done
2024-01-29T20:28:39.9510650Z -- Check for working CXX compiler: /opt/homebrew/opt/llvm@16/bin/clang++ - skipped
2024-01-29T20:28:39.9512590Z -- Detecting CXX compile features
2024-01-29T20:28:39.9516040Z -- Detecting CXX compile features - done
2024-01-29T20:28:39.9528770Z -- Setting build type to 'Release' as none was specified.
2024-01-29T20:28:39.9555020Z -- Performing Test GXX_SUPPORTS_VISIBILITY
2024-01-29T20:28:40.0586960Z -- Performing Test GXX_SUPPORTS_VISIBILITY - Success
2024-01-29T20:28:40.1193790Z -- Info: DCMTK TIFF support will be enabled
2024-01-29T20:28:40.2960780Z -- Info: DCMTK PNG support will be enabled
2024-01-29T20:28:40.4601580Z -- Performing Test OPENSSL_VERSION_CHECK
2024-01-29T20:28:40.6547340Z -- Performing Test OPENSSL_VERSION_CHECK - Success
2024-01-29T20:28:40.6549340Z -- Info: DCMTK OPENSSL support will be enabled
2024-01-29T20:28:40.6549680Z -- Looking for dlopen in dl
2024-01-29T20:28:40.7584250Z -- Looking for dlopen in dl - found
2024-01-29T20:28:40.9645010Z -- Info: DCMTK XML support will be enabled
2024-01-29T20:28:40.9664680Z -- Info: DCMTK ZLIB support will be enabled
Our build machine is mac OS 13. With the same setup, we can build for Apple intel chipset. So, we believe the environment configuration is correct. So we are struggling to find out what are we missing to get pass this libitff linking issue. Can anyone please take a look and share their thoughts?

Thanks,
Samee

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

Re: Error building DCMTK with Apple M1 chip

#2 Post by Marco Eichelberg »

The missing symbols are definitely in libtiff. Check if libtiff is really installed, and whether you do have a arm64 version installed.
Check the CMake log files do determine the precise call to the linked, and whether the right libtiff file is referenced there.
We have a nightly build of DCMTK on MacOS with arm64 including libtiff, and have no problems, so this is not a fundamental problem with DCMTK.

samee
Posts: 17
Joined: Thu, 2023-03-30, 15:27

Re: Error building DCMTK with Apple M1 chip

#3 Post by samee »

Hi Marco,

I think the issue is coming from `CMake/3rdparty.cmake` file where we use `TIFF_LIBRARY` and `JPEG_LIBRARY` values. On the CMake side, these are actually `TIFF_LIBRARIES` and `JPEG_LIBRARIES`. After that modification, I was able to resolve the linking issue. I opened a PR in the GitHub repo (https://github.com/DCMTK/dcmtk/pull/93). Can you please take a look?

Thanks,
Samee

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest