Error configuring DCMTK for Android

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
mahanako
Posts: 5
Joined: Tue, 2022-12-20, 09:16

Error configuring DCMTK for Android

#1 Post by mahanako » Thu, 2022-12-22, 09:10

Hi, I'm trying to build dcmtk on Android and I keep failing. This post might be a bit lengthy and I'm sorry for that. But I hope someone finds time for this ^_^'

I have cloned dcmtk 3.6.7 from Github just a few days ago.

I have followed the topic https://forum.dcmtk.org/viewtopic.php?f ... 81&p=21431 to as far as I could far and made some necessary changes in the script dcmtkUseAndroidSDK.cmake itself but to no avail in the end.

What I did:
-------------------------------
1 - line 130
I have changed the emulator path from ~tools/emulator to ~emulator/emulator:
find_program(ANDROID_EMULATOR_PROGRAM emulator PATHS ${ANDROID_SDK_ROOT} PATH_SUFFIXES emulator NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
That was necessary because the tool will otherwise yield this error:
"PANIC: Missing emulator engine program for 'x86' CPUS."

2 - line 132
Using android.bat seems to be deprecated, so I've changed that line to:
find_program(ANDROID_ANDROID_PROGRAM avdmanager.bat PATHS ${ANDROID_SDK_ROOT} PATH_SUFFIXES tools/bin NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
-------------------------------

Doing 1 and 2 makes the parser in line 145 work.
ANDROID_AVAILABLE_AVDS is then "Pixel_XL_API_30;Pixel_XL_API_30_2" (These two AVD are actually the same and work fine).

But the subsequent ANDROID_EMULATOR_AVD stays empty. I forced it to "Pixel_XL_API_30", but that still didn't do the job.
In line 319, the command to start the AVD is called and I invoked it by hand in the terminal to see what it does but it gave an error saying the -prop (ro.emu.uuid=...) passed is unknown.

Just calling ~emulator/emulator.exe -avd Pixel_XL_API_30 in the terminal starts the AVD, so that seems to work. From here on, I have no idea what to do, so I'd need your help. I also ask myself why do I need an AVD? So far, for building and running Android applications I did not need one. I'm using the device directly. As I have understood the configuration steps so far, this leads to the generation of config/arith.h and I guess other files as well. Couldn't that be done with setting an AVD altogether as I could specify the CPU architecture and Android API version and whatnot via variables.

As for general info: I am using the Qt Creator, writing programs in C++, running them on both, PC and Android devices and I'm using the Qt Creator to setup dcmtk. That worked out of the box for the PC (Windows) case, which makes me very happy, but completely failed for Android.

Kind Regards,
mahanako

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

Re: Error configuring DCMTK for Android

#2 Post by Marco Eichelberg » Wed, 2022-12-28, 17:57

Unfortunately, Google has apparently changed the Android SDK quite a bit since we added Android support. I can offer little help other that saying that we're planning to update the Android specific build code, and I hope that this will make it into the next release. In our continuous integration infrastructure, we have an Android build based on API 24 which apparently works. CMake is called with the following parameters:

Code: Select all

/usr/bin/cmake -DCMAKE_BUILD_TYPE:string=RELEASE -DWITH_TESTING:BOOL=ON --no-warn-unused-cli -DANDROID_SDK_ROOT='/home/android-sdk-linux' -DANDROID_EMULATOR_AVD='testAVD8' -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=24 -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_ANDROID_NDK='/home/android-sdk-linux/ndk-bundle' -DCMAKE_ANDROID_STL_TYPE=gnustl_static -G "Unix Makefiles" "/home/builder/nightly/dcmtk-GCC-8.3.0-posix-x86_64-linux-gnu-_Android_"

mahanako
Posts: 5
Joined: Tue, 2022-12-20, 09:16

Re: Error configuring DCMTK for Android

#3 Post by mahanako » Sat, 2022-12-31, 17:07

Thanks for your answer and for posting the parameters. Though switching to API 24 is still possible, it does not change the current Android toolchain, which cannot be downgraded easily, so I'm still stuck at the AVD not being started and I guess I have to hope for the next release then.

If it's not too much of a nuisance, could you tell me which files need to be generated by running a program on an AVD? So far I only figured out arith.h but I guess, there a lot more. Or is this documented somewhere?

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

Re: Error configuring DCMTK for Android

#4 Post by Marco Eichelberg » Thu, 2023-01-05, 11:43

Basically, you need the device emulator to create the arith.h file. Once you have that, consult the installation instructions (INSTALL file), which provide the following information on cross-compiling DCMTK:

Code: Select all

CROSS COMPILING WITH CMAKE
==========================

The main challenge when cross-compiling DCMTK is that some of the feature tests
performed by CMake require certain small test programs to be compiled and run,
which does not work in a cross-compilation setting.  Starting with DCMTK 3.6.7,
basic support for cross-compilation has been added.  This can be enabled by
setting the CMake variable "DCMTK_NO_TRY_RUN":

  cmake -DDCMTK_NO_TRY_RUN:BOOL=TRUE

In this case, CMake expects all test results that are normally achieved by
executing certain test programs to be provided by the user on the command line.
In detail, these are the variables that need to be provided:

  The following variables are only used when compiling with libiconv support
  and can otherwise be set to default values:
  - DCMTK_ICONV_FLAGS_ANALYZED: should always be set to TRUE
  - DCMTK_FIXED_ICONV_CONVERSION_FLAGS: The output printed by the test program
    config/tests/iconv.cc, when run on the target platform. This value is only
    used when compiling with old libiconv versions (older than libiconv 1.8)
    and determines the iconv behaviour when encountering illegal byte sequences
    during a character set conversion. Possible values are:
    - "AbortTranscodingOnIllegalSequence" (use as default)
    - "DiscardIllegalSequences"
  - DCMTK_STDLIBC_ICONV_HAS_DEFAULT_ENCODING: true if the test program
    config/tests/lciconv.cc exits with a return code of zero, false otherwise.
    This test determines if libiconv has a default encoding, i.e. if
    iconv_open() accepts "" as an argument. Use FALSE as default.

  The following variables are only used when compiling with DCMTK_ENABLE_STL
  and can otherwise be set to 0:
  - HAVE_STL_VECTOR_TEST_RESULT: 1 if the platform provides a working
    <vector> implementation, 0 otherwise
  - HAVE_STL_ALGORITHM_TEST_RESULT: 1 if the platform provides a working
    <algorithm> implementation, 0 otherwise
  - HAVE_STL_LIMITS_TEST_RESULT: 1 if the platform provides a working
    <limits> implementation, 0 otherwise
  - HAVE_STL_LIST_TEST_RESULT: 1 if the platform provides a working
    <list> implementation, 0 otherwise
  - HAVE_STL_MAP_TEST_RESULT: 1 if the platform provides a working
    <map> implementation, 0 otherwise
  - HAVE_STL_MEMORY_TEST_RESULT: 1 if the platform provides a working
    <memory> implementation, 0 otherwise
  - HAVE_STL_STACK_TEST_RESULT: 1 if the platform provides a working
    <stack> implementation, 0 otherwise
  - HAVE_STL_STRING_TEST_RESULT: 1 if the platform provides a working
    <string> implementation, 0 otherwise
  - HAVE_STL_TYPE_TRAITS_TEST_RESULT: 1 if the platform provides a working
    <type_traits> implementation, 0 otherwise
  - HAVE_STL_TUPLE_TEST_RESULT: 1 if the platform provides a working
    <tuple> implementation, 0 otherwise
  - HAVE_STL_SYSTEM_ERROR_TEST_RESULT: 1 if the platform provides a working
    <system_error> implementation, 0 otherwise

  Furthermore, the file "arith.h" must be generated and copied to
  config/include/dcmtk/config/arith.h in the **build** directory.
  This file can be generated by compiling config/tests/arith.cc
  and running the executable on the target platform.

For further information on cross-compiling DCMTK, see:
https://support.dcmtk.org/redmine/projects/dcmtk/wiki/Cross_Compiling

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest