Android installation
Moderator: Moderator Team
Android installation
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?
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: Android installation
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.
Re: Android installation
I used the public release, not the repository. Should I rebuild from the latest commit?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.
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: Android installation
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?
Re: Android installation
Correct, I used r10e. I will be trying to make use of CMake in my project today.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?
Re: Android installation
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:
CmakeLists.txt
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?
Code: Select all
-- 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
Code: Select all
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)
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: Android installation
Modify your CMakeLists.txt to use find_package() in CONFIG mode, as explained here.
Code: Select all
- find_package(DCMTK)
+ find_package(DCMTK CONFIG)
Re: Android installation
Thank you. However I am still not familiar with cmake builds. CmakeLists.txt looks like this:Jan Schlamelcher wrote:Modify your CMakeLists.txt to use find_package() in CONFIG mode, as explained here.Code: Select all
- find_package(DCMTK) + find_package(DCMTK CONFIG)
Code: Select all
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)
Code: Select all
CMake Error at CMakeLists.txt:9 (target_link_libraries):
Cannot specify link libraries for target "DCMTK" which is not built by this project.
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: Android installation
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: Select all
add_executable(my_executable my_cpp_source_file)
target_link_libraries(my_executable ${DCMTK_LIBRARIES})
Re: Android installation
As I did not create any additional cpp files (executables or libs), I defined the executable like this:
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
Code: Select all
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)
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: Android installation
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).
Re: Android installation
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?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).
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: Android installation
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?
Re: Android installation
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.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?
-
- OFFIS DICOM Team
- Posts: 318
- Joined: Mon, 2014-03-03, 09:51
- Location: Oldenburg, Germany
Re: Android installation
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.
Who is online
Users browsing this forum: No registered users and 1 guest