[Cocoa, healthcare] compile DCMTK on iOS platform

Source: Internet
Author: User

Compile DCMTK on iOS platform

Luo chaohui (http://www.cnblogs.com/kesalin)

This article follows the "signature-non-commercial use-consistency" creation public agreement

DCMTK is GermanyOffisThe cross-platform open-source C ++ library developed by the company to implement DICOM protocol is well known in the medical field. It supports platforms such as Windows, Linux, Mac OS, and sun. However, it seems that DCMTK is compiled on the iOS platform.There are very few documents. After a long time, the compilation was successful and recorded.

My compilation environment:
Mac OS 10.6
Xcode 4.0.2
For ios sdk 4.3

Postscript:For iOS 5, both simulator and device compilation can be successful.

 

1. First download the latest DCMTK: http://www.dcmtk.org/. the current region is: dcmtk-3.6.0;

 

2. download the latest cmake: http://www.cmake.org/and install it;

 

3, extract dcmtk to the dcmtk-3.6.0, and create the directory DCMTK-xcode;

 

4. Run cmake and follow the steps shown in:

4.1. Set the DCMTK source file directory and compilation directory

4.2. Click Configure. In the displayed dialog box, select xcode:

4.3. If configure runs, error, don't worry!

4.4. Configure the cmake option:

Doxygen: Off
OpenSSL: Off (Optional: You need to have OpenSSL libs for iOS)
PNG: Off (optional)
Private_tags: On (optional)
Threads: Off (optional)
Tiff: Off (optional)
XML: Off (optional)
Zlib: On (optional)

4.5. Click Configure again to run it. This time there should be no errors;

4.6. Click Generate to generate the xcode project named DCMTK. xcodeproj under DCMTK-xcode.

 

5. Open the DCMTK. xcodeproj project, click the project name, view build setting, set the base SDK to latest Mac OS (Mac OS 10.x), and compile the target to all_build;

 

6. Compile and run the program. It takes a long time to compile. You can go to http://code.google.com/p/ios-static-libraries/to download other compiled Lib for iOS, such as zlib and OpenSSL.

 

7. There should be no compilation error. If libc. h cannot be found, you can directly comment this line and build again!

 

8. After the compilation is successful, click the project name, view build setting, set base SDK to latest IOS (ios x), set ubuntures to standard, and set build active architecture to yes only;

 

9. Modify the target dependencies of all_build in the targets List and delete all non-lib dependencies:

 

10. Compile all_build again. If no error is reported, congratulations! DCMTK has been compiled successfully!

 

11. Create the DCMTK directory and copy the related include and. A lib files to the corresponding directory. The final directory structure is as follows:

Copy dcmtk-3.6.0/XXX/include to DCMTK/include/DCMTK/XXX (alias t for config)
Copy DCMTK-xcode/include/DCMTK/config to DCMTK/include/DCMTK/config
Copy zlib. h to DCMTK/include/zlib. h
Copy DCMTK-xcode/XXX/libsrc/debug-iphoneplatform/libxxx. A to DCMTK/lib-iphoneplatform/libxxx.
Copy libz. A to DCMTK/lib-iphoneplatform/libz.

Include:

Libs:

 

12. Create an iOS appProgramProject, copy the folder above to the project directory, and set the build setting/header search paths of the project to pathtoyourdcmtk/DCMTK/include, then append libplatform/* to build phases/link binary with libraries in the target project /*. file.

 

13. In A. MM file (mixed with C ++, you can modify the suffix of an existing file), import the header file and writeCodeTest:

# Include <DCMTK/config/osconfig. h>
# Include <DCMTK/dcmdata/dcfilefo. h>
# Include <DCMTK/dcmdata/dcdeftag. h>

Nsstring * dcmfilename = @" /Users/luozhaohui/2.dcm " ;
Dcmfileformat fileformat;
Ofcondition loadstatus = fileformat. LoadFile ([dcmfilename utf8string]);
If (Loadstatus. Good ())
{
Ofstring patientname;
Ofcondition findstutas = fileformat. getdataset ()-> findandgetofstring (dcm_patientname, patientname );
If (Findstutas. Good ())
{
Nsstring * name = [nsstring stringwithuf8string: patientname. c_str ()];
Nslog ( @" >>%@ Patient name is [% @] " , Dcmfilename, name );
}
}
Else
{
Nslog ( @" > Failded to Load % @! " , Dcmfilename );
}

14. If you want to run DCMTK on a device, you need to recompile DCMTK for the iOS device version and then link the new DCMTK device version library. Then compile the app. If an error similar to "undefined symbols for architecture armv7:" _ inflateend "occurs, you can set other linker flags to/usr/lib/libz in build setting. dylib.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.