Cross compile for android with ndk 17 fail with "/cache/arit

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
himanshu.mistri
Posts: 18
Joined: Tue, 2018-06-05, 10:21

Cross compile for android with ndk 17 fail with "/cache/arit

#1 Post by himanshu.mistri »

Hello,

I am trying to build library for android and i am stuck with following error:

Reusing already running Android device emulator...
Info: DCMTK ZLIB support will be enabled
Info: DCMTK will compile without built-in (compiled-in) dictionary
Info: DCMTK will try to load external dictionary from default path on startup
Info: DCMTK's builtin private dictionary support will be disabled
Info: Thread support will be enabled
Info: Wide char file I/O functions will be disabled
Info: Wide char main function for command line tools will be disabled
Info: Building DCMTK without character set conversion support
Info: Building DCMTK with large file support (LFS)
Info: C++11 features disabled
Info: STL vector support disabled
Info: STL algorithm support disabled
Info: STL limits support disabled
Info: STL list support disabled
Info: STL map support disabled
Info: STL memory support disabled
Info: STL stack support disabled
Info: STL string support disabled
Info: STL type_traits support disabled
Info: STL tuple support disabled
Info: STL system_error support disabled
CMake Error at CMake/GenerateDCMTKConfigure.cmake:1271 (message):
"/cache/arith.cc": error: only position independent executables (PIE) are
supported.

Aborted

Call Stack (most recent call first):
CMakeLists.txt:53 (INSPECT_FUNDAMENTAL_ARITHMETIC_TYPES)



Configuring incomplete, errors occurred!
See also "/home/vinay/DICOMAndroid/android_build_dcmtk_new/CMakeFiles/CMakeOutput.log".
See also "/home/vinay/DICOMAndroid/android_build_dcmtk_new/CMakeFiles/CMakeError.log".

I am using android emulator API 24, ABI arm64-v8a,I think i should use android-17 with armeabi-v7a .

Here is my cmake GUI configuration for android cross compile --> https://drive.google.com/file/d/1-G9dLZ ... sp=sharing

Thanks,
Himanshu

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Cross compile for android with ndk 17 fail with "/cache/

#2 Post by Jan Schlamelcher »

Quick idea: try building DCMTK as shared libs, since that will enable '-pie' (set BUILD_SHARED_LIBS=ON).

If this doesn't help:

Which version of DCMTK are you using?
Which CMake version are you using?
What were your steps for configuring the build (Android toolchain file?)

himanshu.mistri
Posts: 18
Joined: Tue, 2018-06-05, 10:21

Re: Cross compile for android with ndk 17 fail with "/cache/

#3 Post by himanshu.mistri »

Hello Jan,

Thanks for your quick response.

Now I am able to cross compile successfully using this source code ftp://dicom.offis.de/pub/dicom/offis/so ... 6.3.tar.gz.

For android toolchain i have used ndk-bundle/build/cmake/android.toolchain.cmake (NDK 17)
DCMTK version : 3.6.3, Earlier I am trying with 3.6.3DEV+
Cmake = 3.11.4

Thanks,
Himanshu Mistri

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Cross compile for android with ndk 17 fail with "/cache/

#4 Post by Jan Schlamelcher »

Great! For further notice: I asked for the DCMTK and Toolchain file since I remembered that problem from when I was porting DCMTK to Android. In short: normally '-pie' is only given for building shared objects (the workaround you used) but some android devices also require it for statically linked executables. This is something I "fixed" by using another toolchain file that automatically enabled '-pie' in case you configured it for a certain Android version. You are using the toolchain file from the NDK, which one would expect to work correctly since it is maintained by Google, but, well, Google, so who knows.
Since you are also using a quite new version of CMake, you might try the approach described here instead. The CMake folks included much of the toolchain functionality in CMake itself already (in my experience the best implementation I found so far), which you can use by writing a very simple and short toolchain file yourself (as explained in the linked documentation).

durgeshchourey
Posts: 1
Joined: Mon, 2018-09-10, 09:21

Re: Cross compile for android with ndk 17 fail with "/cache/

#5 Post by durgeshchourey »

Hi,
Help me to build dcmtk for android oreo using android ndk toolchain :
Building on Ubuntu with latest cmake version.

Getting following error :-

-- Check for working C compiler: /home/durgeshchourey/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/durgeshchourey/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/durgeshchourey/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /home/durgeshchourey/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'Release' as none was specified.
CMake Error at CMakeLists.txt:53 (INSPECT_FUNDAMENTAL_ARITHMETIC_TYPES):
Unknown CMake command "INSPECT_FUNDAMENTAL_ARITHMETIC_TYPES".


-- Configuring incomplete, errors occurred!
See also "/home/durgeshchourey/Downloads/dcmtk-master/build/CMakeFiles/CMakeOutput.log".



Setting path by running the script which contains :-
------------------------------

rm -rf CMakeCache.txt CMakeFiles CMakeTmp
CROSS_PATH="/home/durgeshchourey/Downloads/Qt/oreo-toolchain/bin/arm-linux-androideabi"
export AR=${CROSS_PATH}-ar
export AS=${CROSS_PATH}-clang
export CC=${CROSS_PATH}-clang
export CXX=${CROSS_PATH}-clang++
export LD=${CROSS_PATH}-ld
export STRIP=${CROSS_PATH}-strip
export CFLAGS="-fPIE -fPIC"
export LDFLAGS="-pie"
export ANDROID_NDK=/home/durgeshchourey/Downloads/Qt/android-ndk-r17b
export CROSS_COMPILE=arm-linux-androideabi-
export ARCH=arm


mkdir build && cd build
cmake -DCMAKE_SYSTEM_NAME=Android -DCMAKE_TOOLCHAIN_FILE=/home/durgeshchourey/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake ..



himanshu.mistri wrote:Hello,

I am trying to build library for android and i am stuck with following error:

Reusing already running Android device emulator...
Info: DCMTK ZLIB support will be enabled
Info: DCMTK will compile without built-in (compiled-in) dictionary
Info: DCMTK will try to load external dictionary from default path on startup
Info: DCMTK's builtin private dictionary support will be disabled
Info: Thread support will be enabled
Info: Wide char file I/O functions will be disabled
Info: Wide char main function for command line tools will be disabled
Info: Building DCMTK without character set conversion support
Info: Building DCMTK with large file support (LFS)
Info: C++11 features disabled
Info: STL vector support disabled
Info: STL algorithm support disabled
Info: STL limits support disabled
Info: STL list support disabled
Info: STL map support disabled
Info: STL memory support disabled
Info: STL stack support disabled
Info: STL string support disabled
Info: STL type_traits support disabled
Info: STL tuple support disabled
Info: STL system_error support disabled
CMake Error at CMake/GenerateDCMTKConfigure.cmake:1271 (message):
"/cache/arith.cc": error: only position independent executables (PIE) are
supported.

Aborted

Call Stack (most recent call first):
CMakeLists.txt:53 (INSPECT_FUNDAMENTAL_ARITHMETIC_TYPES)



Configuring incomplete, errors occurred!
See also "/home/vinay/DICOMAndroid/android_build_dcmtk_new/CMakeFiles/CMakeOutput.log".
See also "/home/vinay/DICOMAndroid/android_build_dcmtk_new/CMakeFiles/CMakeError.log".

I am using android emulator API 24, ABI arm64-v8a,I think i should use android-17 with armeabi-v7a .

Here is my cmake GUI configuration for android cross compile --> https://drive.google.com/file/d/1-G9dLZ ... sp=sharing

Thanks,
Himanshu

Jan Schlamelcher
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 318
Joined: Mon, 2014-03-03, 09:51
Location: Oldenburg, Germany

Re: Cross compile for android with ndk 17 fail with "/cache/

#6 Post by Jan Schlamelcher »

How is your setup, which version of CMake and DCMTK are you using?

Why did you quote himanshu.mistri's post?

Why do you set LDFLAGS etc. and also use a toolchain file? These settings are performed by / should be performed within the toolchain file.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest