How do I use the DCMTK libraries in my own application?

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

  1. Create DCMTK project files with CMake (for demonstration purposes switch all external libraries off).
  2. Open the main project file "dcmtk.dsw" or "dcmtk.sln" in Visual Studio.
  3. Select target ALL_BUILD and compile the complete DCMTK.
  4. Select INSTALL in order to install the DCMTK files to the directory specified using CMake.
  5. 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 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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值