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

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
dachirui
Posts: 2
Joined: Mon, 2020-03-30, 07:56

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

#1 Post by dachirui »

Hello,

I downloaded DCMTK because I need to use DCMSR to create structured reports from a json but I do not know how to use the libraries in my own application on linux. I have follow the steps in INSTALL file:

Code: Select all

mkdir dcmtk-3.6.5-build
cd dcmtk-3.6.5-build
cmake ../dcmtk-3.6.5
ccmake ../dcmtk-3.6.5
make -j8
make DESTDIR=../dcmtk-3.6.5-install install
and now I have three directories:
  • dcmtk-3.6.5
  • dcmtk-3.6.5-build
  • dcmtk-3.6.5-install
My question is about how to use the libraries in my own C++ code application, because it is different than in Windows. I am using Ubuntu 18.04 as OS. If anyone knows how to develop a C++ application using dcmtk libraries in linux I would be pleasured to know about it.

Thank you for your help

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: How do I use the DCMTK libraries in my own application? (Linux)

#2 Post by J. Riesmeier »

Here's an example "CMakeList.txt" file that I used (slightly modified) some years ago for a demo project:

Code: Select all

# DCMTK Demo Project

# declare project
PROJECT(DCMTK_DEMO)

# minimum CMake version required
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)

# specify DCMTK's (default) installation directory
SET(DCMTK_DIRECTORY "/home/user/dcmtk-3.6.5-install" CACHE PATH "Directory where DCMTK library is installed.")

# approach #1: use FIND_PACKAGE() to search for installed DCMTK
#FIND_PACKAGE(DCMTK REQUIRED CONFIG PATHS ${DCMTK_DIRECTORY} NO_DEFAULT_PATH)

# approach #2: include DCMTK's CMake configuration directly
INCLUDE(${DCMTK_DIRECTORY}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/cmake/DCMTKConfig.cmake)

# declare include directories
INCLUDE_DIRECTORIES(${DCMTK_INCLUDE_DIRS})

# declare executable and link required libraries
ADD_EXECUTABLE(demo demo.cc)
TARGET_LINK_LIBRARIES(demo ${DCMTK_LIBRARIES})
Here is the content of "demo.cc":

Code: Select all

#include "dcmtk/config/osconfig.h"
#include "dcmtk/dcmdata/dctk.h"

int main(int argc, char* argv[])
{
    /* iterate over all command line parameters */
    for (int i = 1; i <= argc; i++)
    {
        /* load the specified DICOM file */
        DcmFileFormat dicomFile;
        if (dicomFile.loadFile(argv[i]).good())
        {
            /* and dump its content to the console */
            COUT << "DICOM file: " << argv[i] << OFendl;
            dicomFile.print(COUT);
            COUT << OFendl;
        }
    }

    return 0;
}
Maybe, this is also a good starting point for you.

dachirui
Posts: 2
Joined: Mon, 2020-03-30, 07:56

Re: How do I use the DCMTK libraries in my own application? (Linux)

#3 Post by dachirui »

Thank you very much for your response. I will test it inmediatly and I will investigate from this starting point.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest