DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Sat, 2017-07-22, 03:45

All times are UTC + 1 hour




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Android installation
PostPosted: Wed, 2017-05-03, 07:37 
Offline

Joined: Thu, 2017-04-27, 16:52
Posts: 9
Hello. So I have built an x86 version of dcmtk 3.6.1. Now, after make install I have a bunch of header files and shared libraries in the ndk toolchains directory. How do I use them in my application?


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Wed, 2017-05-03, 09:47 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 193
Location: Oldenburg, Germany
It of course depends on your application. I would recommend using the find_package() mechanism of CMake together with our CMake Exports to include and link DCMTK to your project. But this of course only works if your project uses CMake... Also, did you build DCMTK for Android from our git repository? I did some serious modifications to our Android support in mostly this and this commit.


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Thu, 2017-05-04, 12:58 
Offline

Joined: Thu, 2017-04-27, 16:52
Posts: 9
Jan Schlamelcher wrote:
It of course depends on your application. I would recommend using the find_package() mechanism of CMake together with our CMake Exports to include and link DCMTK to your project. But this of course only works if your project uses CMake... Also, did you build DCMTK for Android from our git repository? I did some serious modifications to our Android support in mostly this and this commit.

I used the public release, not the repository. Should I rebuild from the latest commit?


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Thu, 2017-05-04, 13:16 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 193
Location: Oldenburg, Germany
You should consider it, if you want to be able to update to new DCMTK versions in the future. The main difference of the current code is that you need to provide your own Android Toolchain file (the one included in DCMTK was removed since it was outdated and we do not have the resources to maintain it) and that newer NDK versions are supported. If you successfully built DCMTK you most likely did not used the newest Android NDK, right?


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Fri, 2017-05-05, 06:11 
Offline

Joined: Thu, 2017-04-27, 16:52
Posts: 9
Jan Schlamelcher wrote:
You should consider it, if you want to be able to update to new DCMTK versions in the future. The main difference of the current code is that you need to provide your own Android Toolchain file (the one included in DCMTK was removed since it was outdated and we do not have the resources to maintain it) and that newer NDK versions are supported. If you successfully built DCMTK you most likely did not used the newest Android NDK, right?

Correct, I used r10e. I will be trying to make use of CMake in my project today.


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Mon, 2017-05-08, 11:59 
Offline

Joined: Thu, 2017-04-27, 16:52
Posts: 9
Ok, I built dcmtk from the latest commit and used ndk r12b. Got an error when building with make in the #ifdef HAVE_GETPWNAM_R block (the method was missing I suppose), but rectified it by commenting it out. Now I can't seem to be able to build with cmake in my project with the following output:
Code:
-- Check for working C compiler: D:/android-ndk-r12b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe
-- Check for working C compiler: D:/android-ndk-r12b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang.exe -- 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: D:/android-ndk-r12b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
-- Check for working CXX compiler: D:/android-ndk-r12b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Trying to find DCMTK expecting DCMTKConfig.cmake
-- Trying to find DCMTK expecting DCMTKConfig.cmake - failed
-- Trying to find DCMTK relying on FindDCMTK.cmake
-- Please set DCMTK_DIR and re-run configure (missing:  DCMTK_config_INCLUDE_DIR DCMTK_dcmdata_INCLUDE_DIR DCMTK_dcmimage_INCLUDE_DIR DCMTK_dcmimgle_INCLUDE_DIR DCMTK_dcmjpeg_INCLUDE_DIR DCMTK_dcmjpls_INCLUDE_DIR DCMTK_dcmnet_INCLUDE_DIR DCMTK_dcmpstat_INCLUDE_DIR DCMTK_dcmqrdb_INCLUDE_DIR DCMTK_dcmsign_INCLUDE_DIR DCMTK_dcmsr_INCLUDE_DIR DCMTK_dcmtls_INCLUDE_DIR DCMTK_ofstd_INCLUDE_DIR DCMTK_oflog_INCLUDE_DIR DCMTK_LIBRARIES)
-- Trying to find DCMTK relying on FindDCMTK.cmake - ok
-- Configuring done
-- Generating done
-- Build files have been written to: C:/dev/trunk/eScrollAndroid/app/.externalNativeBuild/cmake/debug/x86


CmakeLists.txt
Code:
cmake_minimum_required(VERSION 2.8)
project(dcmtk)
SET(DCMTK_DIR "C:/Program Files (x86)/DCMTK/include/dcmtk")
find_package(DCMTK)
if (DCMTK_FOUND)
  include_directories(${DCMTK_INCLUDE_DIRS})
  target_link_libraries (target_link_libraries(dcmtk ${DCMTK_LIBRARIES}))
endif (DCMTK_FOUND)


Cmake cannot find the config file, which is located in the path C:\Program Files (x86)\DCMTK\lib\cmake\dcmtk\DCMTKConfig.cmake. What am I missing here?


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Mon, 2017-05-08, 14:51 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 193
Location: Oldenburg, Germany
Modify your CMakeLists.txt to use find_package() in CONFIG mode, as explained here.
Code:
- find_package(DCMTK)
+ find_package(DCMTK CONFIG)


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Tue, 2017-05-09, 08:23 
Offline

Joined: Thu, 2017-04-27, 16:52
Posts: 9
Jan Schlamelcher wrote:
Modify your CMakeLists.txt to use find_package() in CONFIG mode, as explained here.
Code:
- find_package(DCMTK)
+ find_package(DCMTK CONFIG)

Thank you. However I am still not familiar with cmake builds. CmakeLists.txt looks like this:
Code:
SET(DCMTK_DIR "C:/Program Files (x86)/DCMTK/lib/cmake/dcmtk")
find_package(DCMTK CONFIG REQUIRED)
if (DCMTK_FOUND)
  include_directories(${DCMTK_INCLUDE_DIRS})
  target_link_libraries (DCMTK ${DCMTK_LIBRARIES})
endif (DCMTK_FOUND)

It finds the configuration file, but still gives an error:
Code:
CMake Error at CMakeLists.txt:9 (target_link_libraries):
  Cannot specify link libraries for target "DCMTK" which is not built by this project.

Any ideas?


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Tue, 2017-05-09, 09:52 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 193
Location: Oldenburg, Germany
Yes, thats also an error. target_link_libraries() is meant to link the libraries (in this case the DCMTK libraries) to an executable or library that you created. For example:
Code:
add_executable(my_executable my_cpp_source_file)
target_link_libraries(my_executable ${DCMTK_LIBRARIES})


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Wed, 2017-05-10, 06:54 
Offline

Joined: Thu, 2017-04-27, 16:52
Posts: 9
As I did not create any additional cpp files (executables or libs), I defined the executable like this:
Code:
add_executable(android "")
set_target_properties(android PROPERTIES LINKER_LANGUAGE CXX)
SET(DCMTK_DIR "C:/Program Files (x86)/DCMTK/lib/cmake/dcmtk")
find_package(DCMTK CONFIG REQUIRED)
if (DCMTK_FOUND)
  include_directories(${DCMTK_INCLUDE_DIRS})
  target_link_libraries (android ${DCMTK_LIBRARIES})
endif (DCMTK_FOUND)


Now it seems no errors are produced. I can see the libraries listed in my Android project module's cpp folder. Should cmake copy the .so files to some specific directory or is the build complete by now? Because the .apk does not yet contain any libraries. Thanks


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Wed, 2017-05-10, 08:16 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 193
Location: Oldenburg, Germany
I see, so we talked about different things the whole time. The CMake Exports step ist for including DCMTK in your own C++ Android project. If this is not what you want, please clarify instead what is. If you "simply" want to use the dcmtk command line tools, you can copy them to the device using 'adb' and then execute them via a terminal emulator app of your choice or remotely via adb. I have too little experice with creating an .apk on the other hand, so I cannot tell you how to achive that (I tried it once, and it worked, but it was two years ago and I dont remember the details).


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Wed, 2017-05-10, 08:30 
Offline

Joined: Thu, 2017-04-27, 16:52
Posts: 9
Jan Schlamelcher wrote:
I see, so we talked about different things the whole time. The CMake Exports step ist for including DCMTK in your own C++ Android project. If this is not what you want, please clarify instead what is. If you "simply" want to use the dcmtk command line tools, you can copy them to the device using 'adb' and then execute them via a terminal emulator app of your choice or remotely via adb. I have too little experice with creating an .apk on the other hand, so I cannot tell you how to achive that (I tried it once, and it worked, but it was two years ago and I dont remember the details).

Well my intention is to include your cross compiled library in my project. I do not wish to use command line tools. I had the impression that cmake script will include these libs in my project. Was this incorrect?


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Wed, 2017-05-10, 09:20 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 193
Location: Oldenburg, Germany
I am sorry, then I still do not understand. How does your project use the DCMTK libraries without C++ source code that links to them?


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Wed, 2017-05-10, 10:24 
Offline

Joined: Thu, 2017-04-27, 16:52
Posts: 9
Jan Schlamelcher wrote:
I am sorry, then I still do not understand. How does your project use the DCMTK libraries without C++ source code that links to them?

Well, it doesn't yet. I thought that the header files located in the include directory will be linked to the libraries during the cmake build process.


Top
 Profile  
 
 Post subject: Re: Android installation
PostPosted: Wed, 2017-05-10, 10:32 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Mon, 2014-03-03, 09:51
Posts: 193
Location: Oldenburg, Germany
So your project uses the include files? Than you should call target_link_libraries for whatever binaries that result from the source files of your project that use the include files.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group