Error: DCMTK needs stringstream or strstream type

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
linnet
Posts: 9
Joined: Sat, 2005-05-07, 12:53
Location: Cuba
Contact:

Error: DCMTK needs stringstream or strstream type

#1 Post by linnet »

Hi,

I am trying to compile my own program, which uses dcmtk, on Linux (SUSE 7.1).
I got the following error message and I do not understand what it means:

"/home/dcmtk-3.5.3/ofstd/include/ofstream.h:76:2: #error DCMTK needs stringstream or strstream type"

I compile the DCMTK first, I built the dcmtk libraries following the instructions in INSTALL file.
I include "osconfig.h" as the first line of my source and header files.

My compiler version is gcc 2.95.3

I would appreciate any help to solve this problem...

Linnet

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1445
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#2 Post by Marco Eichelberg »

Make sure that you always #include "osconfig.h" before you include any other DCMTK header file. Also, make sure that the compiler does not find another version of "osconfig.h" or "cfunix.h". Both would explain the error message.

linnet
Posts: 9
Joined: Sat, 2005-05-07, 12:53
Location: Cuba
Contact:

#3 Post by linnet »

The compiler does not find another version of "osconfig.h" or "cfunix.h" and I include "osconfig.h" as the first line of my source and header files.
I got the same error message.
I would appreciate any help to solve this problem...

Linnet

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1445
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#4 Post by Marco Eichelberg »

The error message you see indicates that neither HAVE_SSTREAM nor HAVE_STRSTREAM are defined in cfunix.h, which would mean that something has gone severely wrong with the configure process. Re-run DCMTK's configure script, check for errors and inspect the cfunix.h header file that is produces by the configure process. DCMTK needs one string stream class, either the <sstream> or the <strstream> header or their .h counterparts need to be present and configure tests for the presence of these header files.

krebs
Posts: 2
Joined: Wed, 2006-09-06, 10:50
Location: Kiel

#error DCMTK needs stringstream or strstream type

#5 Post by krebs »

Marco Eichelberg wrote:The error message you see indicates that neither HAVE_SSTREAM nor HAVE_STRSTREAM are defined in cfunix.h, which would mean that something has gone severely wrong with the configure process. Re-run DCMTK's configure script, check for errors and inspect the cfunix.h header file that is produces by the configure process. DCMTK needs one string stream class, either the <sstream> or the <strstream> header or their .h counterparts need to be present and configure tests for the presence of these header files.
Hello,

I am just trying to use dcmtk on debian sarge with the following
small test file

#include <osconfig.h>
#include <stdio.h>
#include "dcmimage.h"

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

}

and get the typical error messages
#error DCMTK needs stringstream or strstream type
#error Your C++ compiler cannot handle class templates

indicating that something is wrong with the cfunix.h.
I am using g++-4.0. I am compiling with

g++ -I/usr/include/dcmtk \
-I/usr/include/dcmtk/ofstd \
-I/usr/include/dcmtk/dcmimgle \
-I/usr/include/dcmtk/dcmdata \
t.cc 2>tmp.log

, so that the dmctk-headers are found.


./configure of dcmtmk created the following lines in cfunix.h

/* Define to 1 if you have the <sstream> header file. */
#define HAVE_SSTREAM 1

/* Define to 1 if you have the <sstream.h> header file. */
/* #undef HAVE_SSTREAM_H */

/* Define to 1 if you have the <strstream> header file. */
#define HAVE_STRSTREAM 1

/* Define to 1 if you have the <strstream.h> header file. */
/* #undef HAVE_STRSTREAM_H */

/* Define to 1 if you have the <strstrea.h> header file. */
/* #undef HAVE_STRSTREA_H */

Any help would be appreciated, thanks Andreas

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#6 Post by Jörg Riesmeier »

It seems that you're mixing the old C++ includes and the C++ ANSI includes.

Try to replace

Code: Select all

#include <stdio.h>
with

Code: Select all

#define INCLUDE_CSTDIO
#include "dcmtk/ofstd/ofstdinc.h"
using the current release 3.5.4 (otherwise omit "dcmtk/ofstd/"). Also see configure options --enable-std-includes and --disable-std-includes.

Btw, there are ready-to-use Debian packages of DCMTK.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1445
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#7 Post by Marco Eichelberg »

In addition, instead of using

Code: Select all

#include <osconfig.h>
#include "dcmimage.h"
you should use the following instructions with the current version of DCMTK (3.5.4):

Code: Select all

#include <dcmtk/config/osconfig.h>
#include <dcmtk/dcmimgle/dcmimage.h>
This will permit compilation when you have installed the header files and libraries, e.g. to /usr/include and /usr/lib or /usr/local/include and /usr/local/lib, respectively.

krebs
Posts: 2
Joined: Wed, 2006-09-06, 10:50
Location: Kiel

#8 Post by krebs »

Thanks for your advices, but they did not change the error messages of the compiler indicating problems with osconfig.h .

What really made the difference was adding

-DHAVE_CONFIG_H

into the compiler options. Then worked and works.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Baidu [Spider] and 1 guest