Compiling Simple dcmtk Program - DICOM

This is a discussion on Compiling Simple dcmtk Program - DICOM ; Hi, I am trying to compile a simple 4-lines program (t.cpp -- given below) using dcmtk. All the header files in the toolkit are in the same directory as t.cpp /* t.cpp */ #include #include "dcmimage.h" int main() { FILE ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Compiling Simple dcmtk Program

  1. Compiling Simple dcmtk Program

    Hi,
    I am trying to compile a simple 4-lines program (t.cpp -- given below)
    using dcmtk.
    All the header files in the toolkit are in the same directory as t.cpp

    /* t.cpp */
    #include
    #include "dcmimage.h"

    int main()
    {
    FILE *ppm = fopen("t.ppm","w");
    DicomImage di = new DicomImage("t.dcm");
    di.writePPM(ppm);
    return 0;
    }

    During Compilation, the following errors occur:

    In file included from ofconsol.h:68,
    from dcitem.h:39,
    from diimage.h:39,
    from dimoimg.h:41,
    from dcmimage.h:41,
    from t.cpp:22:
    ofstream.h:76:2: #error DCMTK needs stringstream or strstream type
    In file included from ofconsol.h:68,
    from dcitem.h:39,
    from diimage.h:39,
    from dimoimg.h:41,
    from dcmimage.h:41,
    from t.cpp:2:
    ofstream.h:102: syntax error before `;' token
    ofstream.h:103: syntax error before `;' token
    ofstream.h:104: syntax error before `;' token
    In file included from dcpcache.h:39,
    from dcitem.h:45,
    from diimage.h:39,
    from dimoimg.h:41,
    from dcmimage.h:41,
    from t.cpp:2:
    oflist.h:58:2: #error Your C++ compiler cannot handle class templates:
    oflist.h:498:2: #error Your C++ Compiler is not capable of compiling
    this code
    t.cpp: In function `int main()':
    t.cpp:7: conversion from `DicomImage*' to non-scalar type `DicomImage'
    requested


    Can somebody please tell me what is wrong in the code. Please see the
    last error also. (Conversion from 'DicomImage*' to 'DicomImage')

    Regards,
    Kaustubh

  2. Re: Compiling Simple dcmtk Program

    Kaustubh wrote:
    > Hi,
    > I am trying to compile a simple 4-lines program (t.cpp -- given below)
    > using dcmtk. [...] During Compilation, the following errors occur:
    >
    > In file included from ofconsol.h:68,
    > from dcitem.h:39,
    > from diimage.h:39,
    > from dimoimg.h:41,
    > from dcmimage.h:41,
    > from t.cpp:22:
    > ofstream.h:76:2: #error DCMTK needs stringstream or strstream type
    > oflist.h:58:2: #error Your C++ compiler cannot handle class templates:
    > oflist.h:498:2: #error Your C++ Compiler is not capable of compiling this code


    these messages should really not ever happen unless you are using a very
    old compiler. Various DCMTK tools complain here that your compiler does
    not support some C++ features needed to compile DCMTK. These features
    are tested when you run configure (on Unix platforms), resulting in file
    config/include/cfunix.h. For Windows, they are hard-coded in
    config/include/cfwin32.h. Make sure these files are in the include path
    and also make sure that there is no other file of the same name (or
    named "osconfig.h" in the include path - this would exactly explain your
    problem.

    Regards,
    Marco Eichelberg
    OFFIS

  3. Re: Compiling Simple dcmtk Program

    Kaustubh wrote:

    > FILE *ppm = fopen("t.ppm","w");
    > DicomImage di = new DicomImage("t.dcm");
    > di.writePPM(ppm);
    > return 0;

    [...]
    > t.cpp:7: conversion from `DicomImage*' to non-scalar type `DicomImage'
    > requested


    Since you create the instance of class DicomImage with "new" you also
    have to declare the variable "di" as a _pointer_ to class DicomImage:

    DicomImage *di = new DicomImage("t.dcm");
    di->writePPM(ppm);

    This should work. And don't forget to delete the "di" object and to close
    the file "ppm" if you use this code snippet in a "real" application.

    Regards,
    Joerg Riesmeier
    OFFIS

  4. Re: Compiling Simple dcmtk Program

    kaustubh.gandhi@gmail.com (Kaustubh) wrote in message news:...

    > DicomImage di = new DicomImage("t.dcm");
    > di.writePPM(ppm);


    The new operator returns a pointer, so you need di to be a pointer to
    a DicomImage object:

    DicomImage * di = new DicomImage("t.dcm");

    And because di is a pointer you need to dereference it to access the
    member function:

    di->writePPM(ppm);

+ Reply to Thread