Loading Patient File and Outputting Patient Name

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
dave
Posts: 67
Joined: Fri, 2004-11-05, 18:20
Location: Houston, Texas, USA

Loading Patient File and Outputting Patient Name

#1 Post by dave » Mon, 2005-11-21, 17:10

This question is related to "Extracting Tag Data using Borland C++ Builder" on the general list, which I posted last week. We thought we would try to compile first using MSVC++6.0, and then try porting to C++ Builder.

I have created a project, dicomExtract, with a dependency upon dcmdata, which I have as depending upon ofstd, as suggested in the above thread. I have also copied the config dir from dcmtk and pasted it into the project folder. The .cpp file of the new project uses the example code from the dcmtk documentation as below:

//begin file

#include "osconfig.h" // I've added this
#include "dcmtk.h" // and this

int main ()
{
DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("test.dcm");
if (status.good())
{
OFString patientsName;
if (fileformat.getDataset()->findAndGetOFString(DCM_PatientsName, patientsName).good())
{
cout << "Patient's Name: " << patientsName << endl;
} else
cerr << "Error: cannot access Patient's Name!" << endl;
} else
cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;

return 0;
}

//end file

If I set either dcmdata or ofstd as the active project, they compile and link OK. However with dicomExtract as the active project, I get the following errors:

LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
End Pass1
dcmdata.lib(dcuid.obj) : error LNK2001: unresolved external symbol _WSACleanup@0
dcmdata.lib(dcuid.obj) : error LNK2001: unresolved external symbol _gethostbyname@4
dcmdata.lib(dcuid.obj) : error LNK2001: unresolved external symbol _gethostname@8
dcmdata.lib(dcuid.obj) : error LNK2001: unresolved external symbol _WSAStartup@8
dcmdata.lib(dcuid.obj) : error LNK2001: unresolved external symbol _Netbios@4
dcmdata.lib(dcistrmz.obj) : error LNK2001: unresolved external symbol _inflateInit2_
dcmdata.lib(dcistrmz.obj) : error LNK2001: unresolved external symbol _inflateInit_
dcmdata.lib(dcistrmz.obj) : error LNK2001: unresolved external symbol _inflateEnd
dcmdata.lib(dcistrmz.obj) : error LNK2001: unresolved external symbol _inflate
dcmdata.lib(dcostrmz.obj) : error LNK2001: unresolved external symbol _deflateInit2_
dcmdata.lib(dcostrmz.obj) : error LNK2001: unresolved external symbol _deflateEnd
dcmdata.lib(dcostrmz.obj) : error LNK2001: unresolved external symbol _deflate
Debug/DicomExtract.exe : fatal error LNK1120: 12 unresolved externals
Error executing link.exe.

DicomExtract.exe - 13 error(s), 1 warning(s)

I'm wondering if my file includes above are correct, or whether I've omitted something else, such as another module/dependency.

Thank you in advance.

David

Thomas Wilkens
DCMTK Developer
Posts: 117
Joined: Tue, 2004-11-02, 17:21
Location: Oldenburg, Germany
Contact:

#2 Post by Thomas Wilkens » Tue, 2005-11-22, 07:32

See here regarding the linker error, look at the very bottom (netapi32.lib and wsock32.lib). See here regarding the linker warning.

dave
Posts: 67
Joined: Fri, 2004-11-05, 18:20
Location: Houston, Texas, USA

#3 Post by dave » Wed, 2005-11-30, 18:53

Thanks for replying, Thomas.

I've set up my include and lib directories just as I had for compiling DCMTK, which I can do successfully, so I'm thinking that some other issues are causing the linker errors and library warning.

At the risk of sounding stupid, do I need to have a makefile for this small project, as DCMTK does for the full set of tools?

Thanks in advance.

David

Thomas Wilkens
DCMTK Developer
Posts: 117
Joined: Tue, 2004-11-02, 17:21
Location: Oldenburg, Germany
Contact:

#4 Post by Thomas Wilkens » Thu, 2005-12-01, 07:33

You dont have to create a makefile. CMake is used on Windows platforms to turn the use of external libraries on or off. You dont use any functionality from external libraries in your small project.

Do you still have all the errors you mentioned above?

dave
Posts: 67
Joined: Fri, 2004-11-05, 18:20
Location: Houston, Texas, USA

#5 Post by dave » Thu, 2005-12-01, 15:34

Yes. I have the same errors. :(
The project directory looks like this:
top level folder -> dicomExtract folder
sub-folder -> config
sub-folder -> dcmdata
sub-folder -> ofstd
sub-folder -> libpng-1.2.5
sub-folder -> libxml2-2.5.7
sub-folder -> tiff-3.6.1
sub-folder -> zlib-1.2.1
all autocreated project files -> dicomextract.cpp file ( as above in first post )
-> DicomExtract.dsw
-> DicomExtract.dsp
-> etc...
Dependencies are as indicated in my first post, also.

Thanks for any help.

David

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

#6 Post by Marco Eichelberg » Fri, 2005-12-02, 12:02

The unresolved external symbols mean that you are not linking against "netapi32" and "wsock32" (as explained in FAQ #27) and also not linking against zlib (zlib_o.lib) from the DCMTK support libraries.
The library conflict means that some part of your code was not compiled with /MT as code generation option, but with something else - /MD, /MTd or /MDd.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest