Feature #784

Cross-compiling support for DCMTK

Added by Marco Eichelberg 3 months ago.

Status:New Start date:2017-07-24
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:Configuration
Target version:-
Module:config Compiler:
Operating System:

Description

Currently it is not possible to cross-compile DCMTK (with the exception of Android).
The reason is that during the compilation process, a few programs are compiled and executed on-the-fly:
  • Autoconf test AC_MY_C_CHAR_UNSIGNED tests if char is unsigned on the C compiler
  • Autoconf test AC_MY_C_RIGHTSHIFT_UNSIGNED tests if the right shift operation is unsigned on the C compiler
  • Autoconf test AC_LIBTIFF_LZW_COMPRESSION tests if libtiff supports LZW compression
  • There are further tests that are used when STL support is enabled
  • The tool config/arith.cc is compiled and run to generate the dcmtk/config/arith.h header file, which described about 50 properties related to the numeric types available in C++ code.

All of the Autoconf tests mentioned above internally use the AC_TRY_RUN macro, which compiles, links and runs a test program.
Equivalent test routines exist inside the CMake build chain.

In order to enable cross-compiling, three alternative solutions are possible:
  1. Support cross-compiling only under the condition that an emulator (or a physical device) is available that can execute the test progams: This is the solution currently implemented for the Android support in DCMTK, which required an Android emulator.
  2. Permit manual creation of header file: All configure macros that require a test program to be run could be moved into a single, separate header file, that could be either created automatically (when not cross-compiling) or manually. This is similar to the cfwin32.h file in older DCMTK releases. If a manually created file is found, the configure tests that require running a program should be skipped.
  3. Offer a stand-alone generation program: This option extends option 2. Additionally to the procedure described in option 2, a stand-alone tests program should be offered that can be cross-compiled, manually transferred to the target machine (or an emulator), and executed there once. This tool would then generate the header file described in option 2, and could be manually transferred back to the cross-compiling installation, and used for cross-compiling DCMTK.
With regard to the current AC_TRY_RUN tests, the following should be noted:
  • The AC_LIBTIFF_LZW_COMPRESSION is of historical interest only and can be completely removed (including its use in dcmj2pnm)
  • For the two tests related to the C compiler it should be checked whether it is possible to implement them as compile-time-only tests
  • arith.cc/arith.h are not needed when STL support (the flag "enable limits") is activated and the contents of the <limits> header file are correct.

Also available in: Atom PDF