DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Thu, 2017-07-27, 05:44

All times are UTC + 1 hour




Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: DCMTK for iOS
PostPosted: Mon, 2012-05-14, 09:52 
Offline

Joined: Wed, 2012-05-02, 12:31
Posts: 11
Location: Netherlands
Hello everyone, I'm a software engineering student currently trying to get the DCMTK library to work on iOS. I have compiled the library with some succes on a Mac OS X environment and I'm currently trying to get dcmdata to read some data from a dicom file. Basically this is a first test to get the hang of working with the library except I can't get the compiler/IDE to find the dcmtk/include directory inside my project... Without this I can never know if I actually compiled the library successfully although building the ALL_BUILD target, generated by CMake, did not give any errors after I fixed some reference issues. Does anyone have any tips on why this might be happening? If you need more information or anything, I will gladly supply it when asked.

Ok, first I will further explain myself a bit. Basically I'm here to share my knowledge and at the same time get some help with the issues I'm having. I will of course share my progress via updates so others can benefit from it as I have enjoyed great support just by reading these forums. I apologize in advance for my English as it is not my primary language.

I'm using the DCMTK 3.6.0 version with Xcode 4.3.1 and iOS 5.1


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Mon, 2012-05-14, 10:37 
Offline
DCMTK Developer

Joined: Fri, 2004-11-05, 13:47
Posts: 1564
Location: Oldenburg, Germany
Hi,

I'm not sure whether I understood the question correctly. I understood you have built DCMTK correctly but in your own project, the DCMTK includes are not found.

Did you run the target "INSTALL"? This copies DCMTK into a well-defined directory structure. Under Unix systems this is usually /usr/local/dcmtk (if I remember correctly), all includes are then found in /usr/local/dcmtk/include. You can change the prefix from /usr/local to anything you like during C-Make configuration phase by editing the variable CMAKE_INSTALL_PREFIX.

Once you have installed DCMTK, adding /usr/local/dcmtk/include to your compiler path should help to find all include files referenced from DCMTK.

HTH,
Michael


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Mon, 2012-05-14, 16:42 
Offline

Joined: Wed, 2012-05-02, 12:31
Posts: 11
Location: Netherlands
Hello,

First of all, thank you for your answer. I realize that this may be the problem and by the install target I assume you mean in the DCMTK Xcode project, generated by CMake. I tried running the target and it gives me the following error:

Code:
/Applications/CMake\ 2.8-8.app/Contents/bin/cmake -DBUILD_TYPE=Debug-iphoneos -P cmake_install.cmake
-- Install configuration: "Debug-iphoneos"
CMake Error at cmake_install.cmake:31 (FILE):
  file cannot create directory: /usr/local/include/dcmtk/config.  Maybe need
  administrative privileges.


make: *** [install_buildpart_0] Error 1
Command /bin/sh failed with exit code 2

I know I may need admin privileges so I tried adding "sudo" before the "/bin/sh" command and before the "make" command in the "Build Phases -> CMake PostBuild Rules" with no result. I tried building the target with the terminal (using xcodebuild) and although it fails finding the *.a files in the Release directory (as I have no such directory), I now have a usr/local/include/dcmtk/config directory with osconfig.h in it.

The command I used to run the install target, from the "DCMTK for xcode" directory, was:

Code:
sudo xcodebuild -target install -sdk iphoneos5.1 -configuration Debug build


I am calling it a day now but will start working on it again first thing in the morning! Will update.


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Mon, 2012-05-14, 17:05 
Offline
DCMTK Developer

Joined: Fri, 2004-11-05, 13:47
Posts: 1564
Location: Oldenburg, Germany
Hi,

right, run the INSTALL target in XCode.

The error occurs definetly because the very target tries to copy all the DCMTK files into /usr/local/dcmtk where a normal user is not permitted to write to.

You use CMake to generate the XCode file, right? During configuration, you see a variable in CMake (use cmake-gui, it is most convenient to use) called DCMTK_INSTALL_PREFIX. There, enter any location you like, where your normal user has write access to.

Best,
Michael


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Tue, 2012-05-15, 15:01 
Offline

Joined: Wed, 2012-05-02, 12:31
Posts: 11
Location: Netherlands
Okay what I have done is this:

I have installed the library in /usr/local/include which worked fine after I used the command I posted earlier twice. After this I still couldn't access the library from Xcode so I decided to skip Mac OS X implementation and go straight to my final goal: iOS. I have actually managed to do get the library working in iOS now and here is how: First, I used this link and translated it to English. Followed all the steps mentioned except I didn't compile the library for the simulator but for my device. I then added those libraries, with the *.a extension, to my own project with the header files with the following directory structure: MyProject/Frameworks/dcmtk/include/dcmdata for headers and MyProject/Frameworks/dcmtk/iphoneos5.1/ for the static libraries.
Then I added the library and header searchpaths to both the project- and the target buildsettings: "$(SRCROOT)/dcmtk/include" and "$(SRCROOT)/dcmtk/iphoneos5.1".

Now I can just create a new objective C++ class (with the .mm extension) and use #import to call everything (like osconfig.h, dcmfilefo.h,dcmimage.h) and it works! Next up is using the dicom.dic as it gives me errors and this will probably mean I need to recompile dcmdata, following the advise I've read here: link

Thank you for your help and if anyone needs help with the compiling or implementing, message me!


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Tue, 2012-05-15, 16:20 
Offline
DCMTK Developer

Joined: Fri, 2004-11-05, 13:47
Posts: 1564
Location: Oldenburg, Germany
Thanks for the hints. However, DCMTK should work wihtout problems on Mac OS X using XCode; but anyway, good that you got it going for iOS. Thanks also for the links :-)

Best,
Michael


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Fri, 2012-06-22, 02:44 
Offline

Joined: Fri, 2012-06-15, 09:12
Posts: 12
Hi jb1989, Can you help me please. I tried to implement all your steps but I got stuck when I compile the DMCTK.xcodeproj, generated by CMake using the terminal. As you post I used the command "sudo xcodebuild -target install -sdk iphoneos 5.1 -configuration Debug build" in the binary directory (call it DCMTK_BIN_DIR for me) where I saved all the files generated by CMake using the DCMTK source code.

When I ran that command, I got this error:

/Users/cib/Memoria SV/DCMTK_SOURCE_DIR/ofstd/include/dcmtk/ofstd/ofstdinc.h:335:10: fatal error: 'libc.h' file not found
#include <libc.h>

Do you know what is such libc.h??? This is killing me. I realized that when I ran the source code with Cmake, it didn`t install the libraries in /usr/local/dcmtk/include. So I decided to install it by the terminal via the terminal but I got this error:

-------------------------------------------------

(cd config && make ARCH="" DESTDIR="" install)
./mkinstalldirs /usr/local/share/doc/dcmtk
mkdir /usr/local/share
mkdir /usr/local/share/doc
mkdir /usr/local/share/doc/dcmtk
/usr/bin/install -c -m 644 docs/config.txt /usr/local/share/doc/dcmtk
/usr/bin/install -c -m 644 docs/envvars.txt /usr/local/share/doc/dcmtk
/usr/bin/install -c -m 644 docs/modules.txt /usr/local/share/doc/dcmtk
/usr/bin/install -c -m 644 docs/dirstruc.txt /usr/local/share/doc/dcmtk
/usr/bin/install -c -m 644 docs/macros.txt /usr/local/share/doc/dcmtk
(cd ofstd && make ARCH="" DESTDIR="" install)
(cd include && make ARCH="" all)
make[2]: Nothing to be done for `all'.
(cd libsrc && make ARCH="" all)
c++ -DHAVE_CONFIG_H -DUSE_NULL_SAFE_OFSTRING -DNDEBUG -c -I. -I. -I../include -I../../config/include \
-O -I/usr/include/libxml2 -D_REENTRANT -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L -Wall oflist.cc
c++ -DHAVE_CONFIG_H -DUSE_NULL_SAFE_OFSTRING -DNDEBUG -c -I. -I. -I../include -I../../config/include \
-O -I/usr/include/libxml2 -D_REENTRANT -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L -Wall ofstring.cc
In file included from ofstring.cc:42:
In file included from ../include/dcmtk/ofstd/ofstring.h:63:
In file included from ../include/dcmtk/ofstd/ofstdinc.h:335:
In file included from /usr/include/libc.h:44:
In file included from /usr/include/sys/mount.h:76:
In file included from /usr/include/sys/attr.h:42:
/usr/include/sys/ucred.h:91:2: error: unknown type name 'u_long'; did you mean
'ulong'?
u_long cr_ref; /* reference count */
^~~~~~
ulong
../../config/include/dcmtk/config/cfunix.h:413:23: note: 'ulong' declared here
typedef unsigned long ulong;
^
In file included from ofstring.cc:42:
In file included from ../include/dcmtk/ofstd/ofstring.h:63:
In file included from ../include/dcmtk/ofstd/ofstdinc.h:335:
In file included from /usr/include/libc.h:44:
In file included from /usr/include/sys/mount.h:76:
In file included from /usr/include/sys/attr.h:42:
/usr/include/sys/ucred.h:133:9: error: unknown type name 'u_int'
u_int cr_version; /* structure layout version */
^
In file included from ofstring.cc:42:
In file included from ../include/dcmtk/ofstd/ofstring.h:63:
In file included from ../include/dcmtk/ofstd/ofstdinc.h:335:
In file included from /usr/include/libc.h:44:
In file included from /usr/include/sys/mount.h:76:
/usr/include/sys/attr.h:80:2: error: unknown type name 'u_short'; did you mean
'short'?
u_short bitmapcount; /* number of attr. bit ...
^
/usr/include/sys/attr.h:444:2: error: unknown type name 'u_long'; did you mean
'ulong'?
u_long maxmatches;
^~~~~~
ulong
../../config/include/dcmtk/config/cfunix.h:413:23: note: 'ulong' declared here
typedef unsigned long ulong;
^
In file included from ofstring.cc:42:
In file included from ../include/dcmtk/ofstd/ofstring.h:63:
In file included from ../include/dcmtk/ofstd/ofstdinc.h:335:
In file included from /usr/include/libc.h:44:
In file included from /usr/include/sys/mount.h:76:
/usr/include/sys/attr.h:456:2: error: unknown type name 'u_char'; did you mean
'uchar'?
u_char reserved[556]; // ...
^~~~~~
uchar
../../config/include/dcmtk/config/cfunix.h:401:23: note: 'uchar' declared here
typedef unsigned char uchar;
^
5 errors generated.
make[2]: *** [ofstring.o] Error 1
make[1]: *** [libsrc-all] Error 2
make: *** [ofstd-install] Error 2

-------------------------------------------------

Any idea to get over these issues ?????

Thanks

Samuel


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Thu, 2012-08-09, 09:03 
Offline

Joined: Tue, 2012-08-07, 08:30
Posts: 15
Hello @russes,

I am interested in knowing the instructions you followed to build dcmtk 3.6.1 for Xcode 4.3 apart from that chinese build stuff. Are you willing to post it here?


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Thu, 2016-02-25, 23:37 
Offline

Joined: Fri, 2012-02-24, 02:28
Posts: 6
I have something that might be of interest...

I have a copy of the DCMTK tree that has been modified to quietly build the DCMTK libraries under iOS. You can build the iOS libraries using Xcode or using the standard Unix command line tools, for both x86 and ARM.

If you would like to play with this, let me know. If you can improve this, I'd love to see the changes.

Note: Since iOS cannot run a command-line tool, this build is for the DCMTK libraries only.


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Tue, 2016-03-01, 10:15 
Offline
DCMTK Developer

Joined: Fri, 2004-11-05, 13:47
Posts: 1564
Location: Oldenburg, Germany
Hi russes,

maybe you can upload your code somewhere and link it here, so everbody who's interested (including us as time permits) can have a look. Thanks!

Michael


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Thu, 2016-08-11, 00:20 
Offline

Joined: Fri, 2012-02-24, 02:28
Posts: 6
Here you go…

My modified version of DCMTK will build the DCMTK libraries for use with iOS.

There are no custom shell scripts that produce this build. I’ve made small modifications to some of the CMake files in the standard DCMTK tree & I’ve added an iOS.cmake file to the top-level CMake directory.

My iOS.cmake file is derived from the iOS.cmake configuration file created by Google. Other projects, like OpenCV, have used the same file for their iOS build.

You can find my version of the DCMTK tree, here:

https://russes@bitbucket.org/afabsoftwa ... public.git

When you grab a copy, the afab branch contains the iOS modifications.

To build, let’s assume I have a copy of the DCMTK tree in the “latest_dcmtk” directory. To configure the build, I use these commands:

mkdir latest_dcmtk.iOS <<— in the same directory as latest_dcmtk
cd latest_dcmtk.iOS

cmake -DIOS_PLATFORM=SIMULATOR64 -G “Unix Makefiles” ../latest_dcmtk

- or -

cmake -DIOS_PLATFORM=SIMULATOR64 -G Xcode ../latest_dcmtk

Use the first cmake command to create a command-line build. Use the second cmake command to build using Xcode.

Most iOS developers will want to use the second cmake command.

To build the library:

make <<— command line build

- or -

open DCMTK.xcodeproj <<— to open under Xcode

To build on Xcode, use the ALL_BUILD scheme.

When the build is complete, you’ll want to either “make install” for a command line build or run the “INSTALL” scheme from Xcode. This will create an “install” directory in your build area, with the built installation tree installed there.

For most iOS developers, building under “SIMULATOR64” should get what you want. When you want to test on your device, clean the Xcode project and build for ARM on your device.

NOTE

There are lot of LLVM compiler options set to make this build proceed silently.

This build is brittle. If you change build options for iOS or macOS, you should test your modifications by performing a test build for the other platform.

I only build the iOS libraries. Command-line ARM binaries are verboten by Apple. You can make the command line build generate Command-line ARM binaries, but they won’t work.

The arithmetic tests that are part of the build are still done on Intel.

Google’s iOS.cmake file is single-architecture. If you try to modify this file to build multiple architectures at once, your build will most likely fail.

I’ve been working with Xcode 7 and the iOS 9.3 developer kit. If you’re trying to make this work with earlier version of Xcode & the iOS developer kit, you’re on your own.


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Wed, 2016-11-23, 18:27 
Offline

Joined: Fri, 2006-07-14, 19:18
Posts: 9
Hi russes,

have you had success compiling your cmake against XCode 8?

I'm trying to get a working install of DCMTK's libraries on XCode 8 for iOS and macOS (Sierra).

using: cmake -DIOS_PLATFORM=SIMULATOR64 -G Xcode ../dcmtk gets me a generated XCode project but throws one warning:

Code:
CMake Warning: Manually-specified variables were not used by the project: IOS_PLATFORM


The XCode project itself is configured against macOS rather than iOS. Regardless of whether I build against macOS/x86 or iOS/arm I run into a series of compilation errors that suggest that the CMake defined compiler switches are not being honored.



To be clear, this second problem also happens when I attempt to compile a CMake generated project using the nightly/snapshot from direct from Offis. A ./configure build successfully creates the command line apps, but leaves me with a DCMTK install that also resists use in a test external project. Again, seemingly because necessary DEFINEs are missing.

(Specifically macros such as USING_STD_NAMESPACE are not being defined, causing 'iostream.h' not found style issues. Similarly, size_t is showing up as undefined. Also properties set in the CMake interface such as use C++ std library are being ignored when I look at the build settings).


Top
 Profile  
 
 Post subject: Re: DCMTK for iOS
PostPosted: Sun, 2016-12-11, 21:39 
Offline

Joined: Fri, 2012-02-24, 02:28
Posts: 6
valley wrote:
have you had success compiling your cmake against XCode 8?

When I build a fresh copy of DCMTK using Xcode 8.2 Beta... my build works correctly. Did you use the "afab" branch for your build?

To make this build work after the Sierra upgrade, I had to reinstall CMake from MacPorts & I had to enable the iPhone 6s configuration in Xcode 8.2 Beta.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2

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:  
Powered by phpBB® Forum Software © phpBB Group