Following is my program --
Code: Select all
#include <iostream>
using namespace std;
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <dcfilefo.h> //in dcmdata
#include <dcitem.h> //in dcmdata
int main()
{
DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("test.dcm");
if (status.good())
{
OFString patientName;
if (fileformat.getDataset()->findAndGetOFString(DCM_PatientName, patientName).good())
{
cout << "Patient's Name: " << patientName << endl;
} else
cerr << "Error: cannot access Patient's Name!" << endl;
}
else
cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;
}
I use following command for compilation on linux
Code: Select all
g++ -I/usr/include/dcmtk/dcmdata -o testProgram testProgram.cc
My dcmtk include files lie in the directory /usr/include/dcmtk
But, I get following error from the compiler.
Code: Select all
In file included from /usr/include/dcmtk/ofstd/ofconsol.h:68,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:39,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/ofstream.h:63:22: error: iostream.h: No such file or directory
/usr/include/dcmtk/ofstd/ofstream.h:64:21: error: fstream.h: No such file or directory
/usr/include/dcmtk/ofstd/ofstream.h:76:2: error: #error DCMTK needs stringstream or strstream type
/usr/include/dcmtk/ofstd/ofstream.h:78:21: error: iomanip.h: No such file or directory
In file included from /usr/include/dcmtk/dcmdata/dcpcache.h:39,
from /usr/include/dcmtk/dcmdata/dcitem.h:45,
from /usr/include/dcmtk/dcmdata/dcsequen.h:43,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:42,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/oflist.h:58:2: error: #error Your C++ compiler cannot handle class templates:
/usr/include/dcmtk/ofstd/oflist.h:498:2: error: #error Your C++ Compiler is not capable of compiling this code
In file included from /usr/include/dcmtk/ofstd/ofconsol.h:68,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:39,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/ofstream.h:102: error: ‘strstream’ does not name a type
/usr/include/dcmtk/ofstd/ofstream.h:103: error: ‘ostrstream’ does not name a type
/usr/include/dcmtk/ofstd/ofstream.h:104: error: ‘istrstream’ does not name a type
In file included from /usr/include/dcmtk/ofstd/ofthread.h:43,
from /usr/include/dcmtk/ofstd/ofconsol.h:69,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:39,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/ofstring.h: In member function ‘const char& OFString::at(size_t) const’:
/usr/include/dcmtk/ofstd/ofstring.h:336: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofstring.h: In member function ‘char& OFString::at(size_t)’:
/usr/include/dcmtk/ofstd/ofstring.h:348: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofstring.h: In member function ‘char OFString::operator[](size_t) const’:
/usr/include/dcmtk/ofstd/ofstring.h:362: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofstring.h: In member function ‘char& OFString::operator[](size_t)’:
/usr/include/dcmtk/ofstd/ofstring.h:375: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofstring.h: In member function ‘size_t OFString::size() const’:
/usr/include/dcmtk/ofstd/ofstring.h:404: error: ‘strlen’ was not declared in this scope
In file included from /usr/include/dcmtk/dcmdata/dcerror.h:38,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:41,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/ofcond.h: In constructor ‘OFCondition::OFCondition(OFConditionString*)’:
/usr/include/dcmtk/ofstd/ofcond.h:321: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofcond.h: In constructor ‘OFCondition::OFCondition(const OFConditionConst&)’:
/usr/include/dcmtk/ofstd/ofcond.h:337: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofcond.h: In copy constructor ‘OFCondition::OFCondition(const OFCondition&)’:
/usr/include/dcmtk/ofstd/ofcond.h:344: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofcond.h: In member function ‘OFCondition& OFCondition::operator=(const OFCondition&)’:
/usr/include/dcmtk/ofstd/ofcond.h:366: error: ‘assert’ was not declared in this scope
In file included from /usr/include/dcmtk/dcmdata/dcpcache.h:39,
from /usr/include/dcmtk/dcmdata/dcitem.h:45,
from /usr/include/dcmtk/dcmdata/dcsequen.h:43,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:42,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/oflist.h: In member function ‘T& OFIterator<T>::operator*() const’:
/usr/include/dcmtk/ofstd/oflist.h:226: error: there are no arguments to ‘assert’ that depend on a template parameter, so a declaration of ‘assert’ must be available
/usr/include/dcmtk/ofstd/oflist.h:226: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
testProgram.cc: In function ‘int main()’:
testProgram.cc:19: error: ‘DCM_PatientName’ was not declared in this scope
[swaroop@schipol dcmtk]$
[swaroop@schipol dcmtk]$ g++ -I/usr/include/dcmtk/dcmdata testProgram.cc
In file included from /usr/include/dcmtk/ofstd/ofconsol.h:68,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:39,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/ofstream.h:63:22: error: iostream.h: No such file or directory
/usr/include/dcmtk/ofstd/ofstream.h:64:21: error: fstream.h: No such file or directory
/usr/include/dcmtk/ofstd/ofstream.h:76:2: error: #error DCMTK needs stringstream or strstream type
/usr/include/dcmtk/ofstd/ofstream.h:78:21: error: iomanip.h: No such file or directory
In file included from /usr/include/dcmtk/dcmdata/dcpcache.h:39,
from /usr/include/dcmtk/dcmdata/dcitem.h:45,
from /usr/include/dcmtk/dcmdata/dcsequen.h:43,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:42,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/oflist.h:58:2: error: #error Your C++ compiler cannot handle class templates:
/usr/include/dcmtk/ofstd/oflist.h:498:2: error: #error Your C++ Compiler is not capable of compiling this code
In file included from /usr/include/dcmtk/ofstd/ofconsol.h:68,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:39,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/ofstream.h:102: error: ‘strstream’ does not name a type
/usr/include/dcmtk/ofstd/ofstream.h:103: error: ‘ostrstream’ does not name a type
/usr/include/dcmtk/ofstd/ofstream.h:104: error: ‘istrstream’ does not name a type
In file included from /usr/include/dcmtk/ofstd/ofthread.h:43,
from /usr/include/dcmtk/ofstd/ofconsol.h:69,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:39,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/ofstring.h: In member function ‘const char& OFString::at(size_t) const’:
/usr/include/dcmtk/ofstd/ofstring.h:336: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofstring.h: In member function ‘char& OFString::at(size_t)’:
/usr/include/dcmtk/ofstd/ofstring.h:348: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofstring.h: In member function ‘char OFString::operator[](size_t) const’:
/usr/include/dcmtk/ofstd/ofstring.h:362: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofstring.h: In member function ‘char& OFString::operator[](size_t)’:
/usr/include/dcmtk/ofstd/ofstring.h:375: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofstring.h: In member function ‘size_t OFString::size() const’:
/usr/include/dcmtk/ofstd/ofstring.h:404: error: ‘strlen’ was not declared in this scope
In file included from /usr/include/dcmtk/dcmdata/dcerror.h:38,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:41,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/ofcond.h: In constructor ‘OFCondition::OFCondition(OFConditionString*)’:
/usr/include/dcmtk/ofstd/ofcond.h:321: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofcond.h: In constructor ‘OFCondition::OFCondition(const OFConditionConst&)’:
/usr/include/dcmtk/ofstd/ofcond.h:337: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofcond.h: In copy constructor ‘OFCondition::OFCondition(const OFCondition&)’:
/usr/include/dcmtk/ofstd/ofcond.h:344: error: ‘assert’ was not declared in this scope
/usr/include/dcmtk/ofstd/ofcond.h: In member function ‘OFCondition& OFCondition::operator=(const OFCondition&)’:
/usr/include/dcmtk/ofstd/ofcond.h:366: error: ‘assert’ was not declared in this scope
In file included from /usr/include/dcmtk/dcmdata/dcpcache.h:39,
from /usr/include/dcmtk/dcmdata/dcitem.h:45,
from /usr/include/dcmtk/dcmdata/dcsequen.h:43,
from /usr/include/dcmtk/dcmdata/dcfilefo.h:42,
from testProgram.cc:8:
/usr/include/dcmtk/ofstd/oflist.h: In member function ‘T& OFIterator<T>::operator*() const’:
/usr/include/dcmtk/ofstd/oflist.h:226: error: there are no arguments to ‘assert’ that depend on a template parameter, so a declaration of ‘assert’ must be available
/usr/include/dcmtk/ofstd/oflist.h:226: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
testProgram.cc: In function ‘int main()’:
testProgram.cc:19: error: ‘DCM_PatientName’ was not declared in this scope