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.