I am trying to create a test application which using dcmdata.
I use CMake to generate dcmtk, then use VS2010 to build it successfully.
CMake was configured by default.
In new Solution for my application I set paths to include headers of dcmtk, and compiled .lib files. In additional dependencies for VC linker, I added files:
dcmdata.lib
netapi32.lib
wsock32.lib
ofstd.lib
At first building my application, i have more than 86 errors. After included #define in my source, number of errors decreased.
My source:
Code: Select all
#define HAVE_CONFIG_H // don't work!
#define DHAVE_CONFIG_H // don't work!
#define HAVE_STRSTREAM
#define HAVE_CLASS_TEMPLATE
#include "dcmtk/config/osconfig.h"
#define HAVE_STD_STRING
#define USE_STD_CXX_INCLUDES // ðàçðåøàåì èñïîëüçîâàíèå èíêëóäû âèäà <iostream>
#define USING_STD_NAMESPACE // ðàçðåøàåì èñïîëüçîâàíèå ñòàíäàðòíîãî ïðîñòðàíñòâà èìåí
#define HAVE_SSTREAM // ðàçðåøàåì èñïîëüçîâàíèå <strstream>
#define PACKAGE_DATE
#define PACKAGE_VERSION
#define PACKAGE_VERSION_NUMBER
#define HAVE_CLASS_TEMPLATE // ðàçðåøàåì èñïîëüçîâàòü øàáëîíû
#define _WIN32
#define WIDE_CHAR_FILE_IO_FUNCTIONS
#define HAVE_STD_NAMESPACE
#define HAVE_STL_LIST // ðàçðåøàåì èñïîëüçîâàòü äèíàìè÷åñêèå ñòðóêòóðû äàííûõ STL
#define HAVE_STL // ðàçðåøàåì èñïîëüçîâàòü äèíàìè÷åñêèå ñòðóêòóðû äàííûõ STL
#define STDIO_NAMESPACE
#define INCLUDE_UNISTD
#define INCLUDE_CSTDIO
#define INCLUDE_CSTRING
#define INCLUDE_CSTDARG
#define INCLUDE_CERRNO
#include "dcmtk/dcmdata/dctk.h"
#include "dcmtk/dcmdata/dcdeftag.h"
#include "dcmtk/dcmdata/dcfilefo.h"
#include "dcmtk/ofstd/ofstring.h"
#include "dcmtk/ofstd/ofcond.h"
#include "dcmtk/ofstd/ofstdinc.h"
#include <iostream>
//using namespace std;
int main()
{
DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("test.dcm");
if (status.good())
{
OFString patientName;
if (fileformat.getDataset()->findAndGetOFString(DCM_PatientName, patientName).good())
{
std::cout << "Patient's Name: " << patientName << std::endl;
}
else
{
std::cerr << "Error: cannot access Patient's Name!" << std::endl;
}
} else
std::cerr << "Error: cannot read DICOM file (" << status.text() << ")" << std::endl;
return 0;
};
But, I'm unsure that I chose the right way.error C2440: =: cannot convert "OFBool" to "FILE *" d:\dcmtk-3.6.0-cmake\ofstd\include\dcmtk\ofstd\offile.h 145 1 dcmtk_test
error C2660: OFFile::freopen: function not have 3 arguments d:\dcmtk-3.6.0-cmake\ofstd\include\dcmtk\ofstd\offile.h 223 1 dcmtk_test
Please help me in to fix this problem.