How do I use the DCMTK libraries in my own applica

Source: Internet
Author: User

Here's an example for the Windows platform (msvc ):

Create DCMTK project files with cmake (for demonstration purposes switch all external libraries off ).
Open the main project file "DCMTK. DSW" or "DCMTK. sln" in Visual Studio.
Select target all_build and compile the complete DCMTK.
Select install in order to install the DCMTK files to the directory specified using cmake.
Create a new directory "testapp" somewhere on your harddisk with the following files.
Example program "testapp. cxx" from the dcmdata documentation:

Code:
# Include "DCMTK/config/osconfig. H"
# Include "DCMTK/dcmdata/dctk. H"

Int main ()
{
Dcmfileformat fileformat;
Ofcondition status = fileformat. LoadFile ("test. DCM ");
If (status. Good ())
{
Ofstring patientsname;
If (fileformat. getdataset ()-> findandgetofstring (dcm_patientsname, patientsname). Good ())
{
Cout <"Patient's name:" <patientsname <Endl;
} Else
Cerr <"error: cannot access patient's name! "<Endl;
} Else
Cerr <"error: cannot read DICOM file (" <status. Text () <")" <Endl;
Return 0;
}

 

Add minimum cmakelists.txt file for msvc6 and adjust path to installed DCMTK (if required ):

 

Code:
Project (testapp)

Set (dcmtk_dir/DICOM/dcmtk-3.5.4-win32-i386)

# Settings for Microsoft Visual C ++ 6
Set (cmake_c_flags "/nologo/W3/GX/Gy/Yx ")
Set (cmake_c_flags_debug "/MTD/z7/OD ")
Set (cmake_c_flags_release "/MT/O2 ")
Set (cmake_cxx_flags "/nologo/W3/GX/Gy/Yx ")
Set (cmake_cxx_flags_debug "/MTD/z7/OD ")
Set (cmake_cxx_flags_release "/MT/O2 ")

Add_definitions (-d_reentrant)

Include_directories ($ {dcmtk_dir}/include)
Link_directories ($ {dcmtk_dir}/LIB)

Add_executable (testapp)
Target_link_libraries (testapp netapi32 wsock32 ofstd dcmdata)

Finally, create the project files for the test application using cmake and compile it using msvc.

 

 

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.