![]() | {{#switch:|User|User talk=This user {{#ifeq:ITK|ITK/Cross Compiling||sub}}page is currently inactive and is retained for historical reference. {{#if: |It was last updated {{{last}}}.}} If you want to revive discussion regarding the subject, you might try contacting the user in question or seeking broader input via a forum such as the village pump.|#default={{#switch:{{{type}}}|policy=This former Wikipedia policy, no longer backed by community consensus, is retained for historical reference.|guideline=This former Wikipedia guideline, no longer backed by community consensus, is retained for historical reference.| |section=This section is currently out-of-date and may contain errors but is retained for historical reference. {{#if: || For peer-reviewed, authoritative guidance on ITK, see The ITK Software Guide.. Additional guidance can be found via the mailing lists.}} |woundup=This page has been closed down by community consensus, and is retained only for historical reference. For peer-reviewed, authoritative guidance on ITK, see The ITK Software Guide. If you wish to restart discussion on the status of this page, seek community input via the mailing lists].|#default=This section is currently out-of-date and may contain errors but is retained for historical reference. {{#if: || For peer-reviewed, authoritative guidance on ITK, see The ITK Software Guide. Additional guidance can be found via the ITK Discourse.}}}} {{#if: |{{{comment}}}|}} {{#if: |It was last updated {{{last}}}.}} }} | {{#if: | {{#if:| }}{{#if:| }}{{#if:| }}{{#if:| }}{{#if: | }}Shortcut{{#if:|s}}: {{#if:
| {{#ifexist: | | }}}} }} |
{{#switch:|User|User talk=|#default={{#ifeq:{{{category}}}|no||}}}}
This page describes the procedure to follow when cross compiling ITK for another system.
In this page, we will refer to the system as:
In this particular case we illustrate
The following is a script developed by Johannes Schindelin (originally intended for FIJI)
Script for Building the Darwing Toolchain in Linux
Following the advice of the CMake Wiki [1]
Put the following in a file called ToolChain.cmake
# this one is important SET(CMAKE_SYSTEM_NAME Linux) #this one not so much SET(CMAKE_SYSTEM_VERSION 1) # specify the cross compiler SET(CMAKE_C_COMPILER /usr/bin/gcc) SET(CMAKE_CXX_COMPILER /usr/bin/g++) # where is the target environment SET(CMAKE_FIND_ROOT_PATH /usr) # search for programs in the build host directories SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # for libraries and headers in the target directories SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
and run it with CMake using the command (in an empty directory)
cmake -DCMAKE_TOOLCHAIN_FILE=./ToolChain.cmake ~/src/ITK
This will generate (among many other things) a File called
TryRunResults.cmake
Then, manually populate, the values of each one of the fields.
The values to be put in this file can be taken from the CMakeCache.txt file of a native build in Darwin.
Finally, copy this file to the build system.
Now that you have copied the TryRunResuls.cmake file to the host system, you can use it as an initial cache for configuring the build.
Do the command in the build system.
cmake -C ~/TryRunResults.cmake ~/src/ITK
once the configuration is completed you can proceed to build ITK by simply typing
make
The process as a whole has been scripted in the file below
Script for configuring a cross-compilation build
Thanks to Johannes Schindelin for contributing the script.
In this particular case we illustrate
Note: the MXE project has an ITK package! Just
cd mxe make itk
The MXE project will build the toolchain nicely, and it even creates a CMake toolchain file.
The following is a script developed by Johannes Schindelin (originally intended for FIJI). Script for Building the Windows (MinGW) Toolchain in Linux
Following the advice of the CMake Wiki [2], put the following in a file called ToolChain.cmake
# this one is important SET(CMAKE_SYSTEM_NAME Linux) #this one not so much SET(CMAKE_SYSTEM_VERSION 1) # specify the cross compiler SET(CMAKE_C_COMPILER /usr/bin/gcc) SET(CMAKE_CXX_COMPILER /usr/bin/g++) # where is the target environment SET(CMAKE_FIND_ROOT_PATH /usr) # search for programs in the build host directories SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # for libraries and headers in the target directories SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Note that if you are using MXE, it already comes with a toolchain file at
mxe/usr/i686-pc-mingw32/share/cmake/mxe-conf.cmake
Run CMake using the command (in an empty directory)
cmake -DCMAKE_TOOLCHAIN_FILE=./ToolChain.cmake ~/src/ITK
This will generate (among many other things) a File called
TryRunResults.cmake
The values to be put in this file can be taken from the CMakeCache.txt file of a native build in Windows. The CMakeCache.txt can be created by manually running a CMake configuration on Windows. Use this script to populate the TryRun results with the Windows CMakeCache.txt contents.
Now that you have copied the TryRunResuls.cmake file to the host system, you can use it as an initial cache for configuring the build.
Do the command in the build system.
cmake -C ~/TryRunResults.cmake ~/src/ITK
once the configuration is completed you can proceed to build ITK by simply typing
make
The build process will fail when trying to create the HDF5 library.
[ 73%] Building C object Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/H5make_libsettings.dir/H5make_libsettings.c.obj Linking C executable ../../../../../../bin/H5make_libsettings.exe [ 73%] Built target H5make_libsettings Scanning dependencies of target H5detect [ 73%] Building C object Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/H5detect.dir/H5detect.c.obj Linking C executable ../../../../../../bin/H5detect.exe [ 73%] Built target H5detect [ 73%] Generating ../H5lib_settings.c /bin/sh: ../../../../../../bin/H5make_libsettings.exe: cannot execute binary file make[2]: *** [Modules/ThirdParty/HDF5/src/itkhdf5/H5lib_settings.c] Error 126 make[1]: *** [Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeFiles/itkhdf5.dir/all] Error 2 make: *** [all] Error 2
Copy the executables that were created on the host system, bin/H5detect.exe and bin/H5make_libsettings.exe to the Windows target and run them,
H5detect > H5Tinit.c H5make_libsettings.exe > H5lib_settings.c
Then copy the results *.c files to Modules/ThirdParty/HDF5/src/itkhdf5/ in the host build tree. Restart the build,
make
In this particular case we illustrate
Following the advice of the CMake Wiki [3]
Put the following in a file called ToolChain.cmake
# this one is important SET(CMAKE_SYSTEM_NAME Linux) #this one not so much SET(CMAKE_SYSTEM_VERSION 1) # specify the cross compiler SET(CMAKE_C_COMPILER /home/ibanez/local/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc) SET(CMAKE_CXX_COMPILER /home/ibanez/local/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++) # where is the target environment SET(CMAKE_FIND_ROOT_PATH /home/ibanez/local/x-tools/arm-unknown-linux-gnueabi) # search for programs in the build host directories SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # for libraries and headers in the target directories SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
and run it with CMake using the command (in an empty directory)
cmake -DCMAKE_TOOLCHAIN_FILE=./ToolChain.cmake ~/src/ITK
This will generate (among many other things) a File called
TryRunResults.cmake
Then, manually populate, the values of each one of the fields.
The values to be put in this file can be taken from the CMakeCache.txt file of a native build in the Raspberry Pi.
For reference,
Now that you have copied the TryRunResuls.cmake file to the host system, you can use it as an initial cache for configuring the build.
Do the command in the build system.
cmake -C ~/TryRunResults.cmake -DCMAKE_TOOLCHAIN_FILE=./ToolChain.cmake ~/src/ITK
once the configuration is completed you can proceed to build ITK by simply typing
make
The build process of the TIFF library requires to first build an executable file called:
in order to generate a file called:
Since, during the cross-compilation process we generate executables that are for a different target architecture, the itkmkg3states file that we built, can't be run in the host to generate the tif_fax2sm.c file.
One way around this is to build the executable for the architecture of the host (e.g. taking it from any other local build of ITK in the host), and use it to replace the itkmkg3states file. Then using it to generate the .c file.
This can be done with the following commands:
Then it is possible to continue with the "make" process.
Once the build finishes, we can package ITK with the command:
this will produce three files (that are independent of each other)
For example, copying the ITK-4.4.0-Linux.tar.gz file to the target, and expanding it there will provide a local installation of ITK against which it is possible to build ITK applications.