Error while building DCMTK lib for ANDROID

Compilation and installation of DCMTK

Moderator: Moderator Team

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

Re: Error while building DCMTK lib for ANDROID

#31 Post by Jan Schlamelcher »

ashajg wrote:And Can you please tell me the name of That CMAKE variable for ANDROID STANDARD LIBRARY so that I can check if it is set or not?
I will have to look it up. I only think I remember there was one, I'm not even a 100% sure.

ashajg
Posts: 30
Joined: Thu, 2018-10-11, 11:10

Re: Error while building DCMTK lib for ANDROID

#32 Post by ashajg »

ok Sir

What I did now is to change CLANG compiler I set ANDROID_TOOLCHAIN_NAME to arm-linux-androideabi-4.9.

After configuring and generating build. I used MSYS and passed mingw32-make command to get this.....
$ mingw32-make
Scanning dependencies of target ofstd
[ 0%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/ofchrenc.cc.o
[ 0%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/ofcmdln.cc.o
[ 0%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/ofconapp.cc.o
[ 0%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/ofcond.cc.o
[ 0%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/ofconfig.cc.o
[ 1%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/ofconsol.cc.o
[ 1%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/ofcrc32.cc.o
[ 1%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/ofdate.cc.o
[ 1%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/ofdatime.cc.o
[ 1%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/oferror.cc.o
[ 1%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/offile.cc.o
[ 1%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/offname.cc.o
[ 1%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/oflist.cc.o
[ 1%] Building CXX object ofstd/libsrc/CMakeFiles/ofstd.dir/ofstd.cc.o
In file included from C:\Ashish\dcmtk-3.6.3\ofstd\include/dcmtk/ofstd/ofpwd.h:32:0,
from C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc:179:
C:\Ashish\dcmtk-3.6.3\ofstd\include/dcmtk/ofstd/ofpwd.h:83:14: error: redeclaration of 'OFString OFStandard::OFPasswd::pw_passwd'
OFString pw_gecos;
^
In file included from C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc:179:0:
C:\Ashish\dcmtk-3.6.3\ofstd\include/dcmtk/ofstd/ofpwd.h:80:14: note: previous declaration 'OFString OFStandard::OFPasswd::pw_passwd'
OFString pw_passwd;
^
C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc: In constructor 'OFStandard::OFPasswd::OFPasswd()':
C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc:2872:1: error: multiple initializations given for 'OFStandard::OFPasswd::pw_passwd'
OFStandard::OFPasswd::OFPasswd()
^
C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc: In constructor 'OFStandard::OFPasswd::OFPasswd(passwd*)':
C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc:2884:1: error: multiple initializations given for 'OFStandard::OFPasswd::pw_passwd'
OFStandard::OFPasswd::OFPasswd( passwd* const p )
^
ofstd\libsrc\CMakeFiles\ofstd.dir\build.make:230: recipe for target 'ofstd/libsrc/CMakeFiles/ofstd.dir/ofstd.cc.o' failed
mingw32-make[2]: *** [ofstd/libsrc/CMakeFiles/ofstd.dir/ofstd.cc.o] Error 1
CMakeFiles\Makefile2:331: recipe for target 'ofstd/libsrc/CMakeFiles/ofstd.dir/all' failed
mingw32-make[1]: *** [ofstd/libsrc/CMakeFiles/ofstd.dir/all] Error 2
Makefile:139: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
:( I am not understanding why I am getting these errors is their any issue with configuration process :(

I am following this :https://support.dcmtk.org/redmine/proje ... ileAndroid

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

Re: Error while building DCMTK lib for ANDROID

#33 Post by Jan Schlamelcher »

Quoting from the page you linked:
ANDROID_STL - the C++ standard library implementation to use. The NDK provides different STL implementations, for example the GNU STL and the multiplatform STLport.
So the variable is named ANDROID_STL
The HowTo is quite old and not necessarily correct in all regards, for example I think one should use MSYS Makefiles instead of MinGW Makefiles.

ashajg
Posts: 30
Joined: Thu, 2018-10-11, 11:10

Re: Error while building DCMTK lib for ANDROID

#34 Post by ashajg »

ok sir.
This is my ANDROID CONFIGURATION
ANDROID_ABD_PROGRAM :C:/Users/212715008/AppData/Local/Android/Sdk/platform-tools/adb.exe
ANDROID_ANDROID_PROGRAM:C:/Users/212715008/AppData/Local/Android/Sdk/tools/android.bat
ANDROID_EMULATOR_AVD:NEXUXDCM
ANDROID_EMULATOR_PROGRAM:C:/Users/212715008/AppData/Local/Android/Sdk/tools/emulator.exe
ANDROID_NATIVE_API_LEVEL: 17
ANDROID_SDK_ROOT:C:\Users\212715008\AppData\Local\Android\Sdk
ANDROID_STL: gnustl_static
ANDROID_STL_SHARED_OBJECT:C:/android-ndk-r15c/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_shared.so
ANDROID_TEMPRORY_FILE_LOCATION:/cache
ANDROID_TOOLCHAIN_NAME: arm-linux-androideabi-4.9

After ensuring this setup still I am facing same errors is something wrong or missing in above setup??
ERRORS:In file included from C:\Ashish\dcmtk-3.6.3\ofstd\include/dcmtk/ofstd/ofpwd.h:32:0,
from C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc:179:
C:\Ashish\dcmtk-3.6.3\ofstd\include/dcmtk/ofstd/ofpwd.h:83:14: error: redeclaration of 'std::string OFStandard::OFPasswd::pw_passwd'
OFString pw_gecos;
^
In file included from C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc:179:0:
C:\Ashish\dcmtk-3.6.3\ofstd\include/dcmtk/ofstd/ofpwd.h:80:14: note: previous declaration 'std::string OFStandard::OFPasswd::pw_passwd'
OFString pw_passwd;
^
C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc: In constructor 'OFStandard::OFPasswd::OFPasswd()':
C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc:2872:1: error: multiple initializations given for 'OFStandard::OFPasswd::pw_passwd'
OFStandard::OFPasswd::OFPasswd()
^
C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc: In constructor 'OFStandard::OFPasswd::OFPasswd(passwd*)':
C:\Ashish\dcmtk-3.6.3\ofstd\libsrc\ofstd.cc:2884:1: error: multiple initializations given for 'OFStandard::OFPasswd::pw_passwd'
OFStandard::OFPasswd::OFPasswd( passwd* const p )
^
ofstd\libsrc\CMakeFiles\ofstd.dir\build.make:233: recipe for target 'ofstd/libsrc/CMakeFiles/ofstd.dir/ofstd.cc.o' failed
mingw32-make[2]: *** [ofstd/libsrc/CMakeFiles/ofstd.dir/ofstd.cc.o] Error 1
mingw32-make[2]: Leaving directory 'c:/Ashish/ashdcm'
CMakeFiles\Makefile2:334: recipe for target 'ofstd/libsrc/CMakeFiles/ofstd.dir/all' failed
mingw32-make[1]: *** [ofstd/libsrc/CMakeFiles/ofstd.dir/all] Error 2
mingw32-make[1]: Leaving directory 'c:/Ashish/ashdcm'
Makefile:142: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

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

Re: Error while building DCMTK lib for ANDROID

#35 Post by Jan Schlamelcher »

I see now. They seem to believe it is a good idea to implement the optional pw_gecos by just mapping it to pw_passwd. While this is fully retarded up to a point it can no longer be explained by mere brain damage the normal way for Google to do things, it might be a serious problem, just look at the specification of struct passwd and ask yourself: what can possibly go wrong if I map the field for "Encrypted password" to the field for "User's full name". Now if they only did this, from a security standpoint, troublesome thing, it would be okay, but they also do it using the preprocessor, rewriting all occurrences of pw_gecos to pw_passwd in code that uses it, leading to the error you've noticed. All so that they can claim to support an optional field in an API they claim to support (I guess they did not notice it was optional).

As a workaround, you may undefine HAVE_PASSWD_GECOS in your osconfig.h (yes, we have a configure test for pw_gecos since it is optional, but this, of course, wont work if somebody were to preprocessor define it to some of the other fields).

EDIT: You may also apply below patch that I'm about to commit to our internal testing repository:

Code: Select all

From 9ce7454847fd1847c121262f5d701abd8c588b1e Mon Sep 17 00:00:00 2001
From: Jan Schlamelcher <dicom@offis.de>
Date: Thu, 8 Nov 2018 10:51:24 +0100
Subject: [PATCH] Added configure test to workaround an Android issue.

---
 CMake/GenerateDCMTKConfigure.cmake | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/CMake/GenerateDCMTKConfigure.cmake b/CMake/GenerateDCMTKConfigure.cmake
index cc9b9af6c..ea0a6f7f7 100644
--- a/CMake/GenerateDCMTKConfigure.cmake
+++ b/CMake/GenerateDCMTKConfigure.cmake
@@ -1277,6 +1277,20 @@ if(NOT DCMTK_ICONV_FLAGS_ANALYZED)
     analyze_iconv_flags()
 endif()
 
+if(HAVE_PASSWD_GECOS AND NOT DEFINED PASSWD_GECOS_IS_DEFINE_TO_PASSWD)
+    DCMTK_TRY_COMPILE(PASSWD_GECOS_IS_DEFINE_TO_PASSWD "pw_gecos is #defined to pw_passwd"
+        "#include <pwd.h>
+int main()
+{
+    struct S { int pw_passwd; };
+    &S::pw_gecos;
+    return 0;
+}")
+    if(PASSWD_GECOS_IS_DEFINE_TO_PASSWD)
+        set(HAVE_PASSWD_GECOS 0 CACHE INTERNAL "Have symbol &passwd::pw_gecos")
+    endif()
+endif()
+
 # Compile config/tests/arith.cc and generate config/arith.h
 function(INSPECT_FUNDAMENTAL_ARITHMETIC_TYPES)
   set(ARITH_H_FILE "${DCMTK_BINARY_DIR}/config/include/dcmtk/config/arith.h")
-- 
2.19.1

ashajg
Posts: 30
Joined: Thu, 2018-10-11, 11:10

Re: Error while building DCMTK lib for ANDROID

#36 Post by ashajg »

So for me now the workaround is to go in osconfig.h in sourcecode of dcmtk and undefine HAVE_PASSWD_GECOS compile it again and then see if it is working....

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

Re: Error while building DCMTK lib for ANDROID

#37 Post by Jan Schlamelcher »

I've edited my post, see above.

ashajg
Posts: 30
Joined: Thu, 2018-10-11, 11:10

Re: Error while building DCMTK lib for ANDROID

#38 Post by ashajg »

Now what i did is just Added a bool entry for HAVE_PASSWD_GECOS in my cmake and kept it unchecked so I got this :

/* Define if passwd::pw_gecos is available */
/* #undef HAVE_PASSWD_GECOS */

in my osconfig.h in build directory....

then again I tried to build it to get the same error.

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

Re: Error while building DCMTK lib for ANDROID

#39 Post by Jan Schlamelcher »

I see. I think we always declare pw_gecos, even if the API below does not provide it. So it makes sense the issue survives. I'll have to do some more workarounds, luckily, Google incompetence wasting time I don't have is an experience I am now quite used to.

ashajg
Posts: 30
Joined: Thu, 2018-10-11, 11:10

Re: Error while building DCMTK lib for ANDROID

#40 Post by ashajg »

adding this patch will remove this issue?

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

Re: Error while building DCMTK lib for ANDROID

#41 Post by Jan Schlamelcher »

Turns out there is no good way to workaround this issue. The best way is probably to put #undef pw_gecos in line 35 of ofstd/include/dcmtk/ofstd/ofpwd.h, but this would of course have the side effect that everyone including this file loses the definition. While this would fix the issue at hand, it might lead to problems later on. There is simply no portable way to temporary undefine a preprocessor marco and the () trick I used for working around Microsoft's min/max defines seems to only work on functions, but not on member variables.
Can you try it with the #undef? If that works, I will perhaps add something like:

Code: Select all

#ifdef PASSWD_GECOS_IS_DEFINED_TO_PASSWD
#undef pw_gecos
#endif
...
#ifdef PASSWD_GECOS_IS_DEFINED_TO_PASSWD
#define pw_gecos pw_passwd
#endif
as the least sucking solution.

ashajg
Posts: 30
Joined: Thu, 2018-10-11, 11:10

Re: Error while building DCMTK lib for ANDROID

#42 Post by ashajg »

ok I ll try this and let you know...

By the way older versions of NDK will work??

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

Re: Error while building DCMTK lib for ANDROID

#43 Post by Jan Schlamelcher »

Last time I tried this issue did not exist.

ashajg
Posts: 30
Joined: Thu, 2018-10-11, 11:10

Re: Error while building DCMTK lib for ANDROID

#44 Post by ashajg »

last time on which ndk version you tried and its been how much time back you tried it?

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

Re: Error while building DCMTK lib for ANDROID

#45 Post by Jan Schlamelcher »

It was during this year, that's all I remember.

Post Reply

Who is online

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