questions about link errors

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
whqyy
Posts: 11
Joined: Fri, 2006-02-10, 09:46

questions about link errors

#1 Post by whqyy »

Hi.
I have built a new project in vs 2005, and added the lib files. The code is as follows:

#include "stdafx.h"

#include <iostream>

#include "dcmtk/dcmdata/dctk.h"

int _tmain(int argc, _TCHAR* argv[])
{
char * FILE_NAME = new char[100] = "D:\\study\\DICOM\\data\\PNEUMATIX\\PNEUMATIX\\Cardiovascular Heart-Cardiac Function\\cine_retro_aortic arch\\IM-0001-0001.dcm";

DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile(FILE_NAME);
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;
}

But when I built it, there were many different link errors, such as:
1>dcmdata.lib(dccodec.obj) : error LNK2001: unresolved external symbol "class OFCondition const EC_Normal" (?EC_Normal@@3VOFCondition@@B)
1>dcmdata.lib(dcvrdt.obj) : error LNK2001: unresolved external symbol "class OFCondition const EC_Normal" (?EC_Normal@@3VOFCondition@@B)

1>dcmdata.lib(dcvrfl.obj) : error LNK2019: unresolved external symbol "class OFCondition const EC_IllegalParameter" (?EC_IllegalParameter@@3VOFCondition@@B) referenced in function "public: __thiscall std::runtime_error::runtime_error(class std::runtime_error const &)" (??0runtime_error@std@@QAE@ABV01@@Z)


I have tried some methods mentioned in faq, but they didn't work at all.

Thank you.

Yingyi

vyrus
Posts: 19
Joined: Sat, 2006-01-21, 22:14

Re: questions about link errors

#2 Post by vyrus »

whqyy wrote:Hi.
I have built a new project in vs 2005, and added the lib files. The code is as follows:

#include "stdafx.h"

#include <iostream>

#include "dcmtk/dcmdata/dctk.h"

int _tmain(int argc, _TCHAR* argv[])
{
char * FILE_NAME = new char[100] = "D:\\study\\DICOM\\data\\PNEUMATIX\\PNEUMATIX\\Cardiovascular Heart-Cardiac Function\\cine_retro_aortic arch\\IM-0001-0001.dcm";

DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile(FILE_NAME);
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;
}

But when I built it, there were many different link errors, such as:
1>dcmdata.lib(dccodec.obj) : error LNK2001: unresolved external symbol "class OFCondition const EC_Normal" (?EC_Normal@@3VOFCondition@@B)
1>dcmdata.lib(dcvrdt.obj) : error LNK2001: unresolved external symbol "class OFCondition const EC_Normal" (?EC_Normal@@3VOFCondition@@B)

1>dcmdata.lib(dcvrfl.obj) : error LNK2019: unresolved external symbol "class OFCondition const EC_IllegalParameter" (?EC_IllegalParameter@@3VOFCondition@@B) referenced in function "public: __thiscall std::runtime_error::runtime_error(class std::runtime_error const &)" (??0runtime_error@std@@QAE@ABV01@@Z)


I have tried some methods mentioned in faq, but they didn't work at all.

Thank you.

Yingyi
You must'v already done this... but you do add ofstd library in your lib dependencies?

whqyy
Posts: 11
Joined: Fri, 2006-02-10, 09:46

#3 Post by whqyy »

I'm sorry, but I don't know what you meant.
Would you please tell in more details?
Thank you very much.

whqyy
Posts: 11
Joined: Fri, 2006-02-10, 09:46

#4 Post by whqyy »

hi
I have added ofstd.lib into aditional dependencies. But there are still some errors as follow:

dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol _WSACleanup@0 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
1>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol _gethostbyname@4 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
1>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol _gethostname@8 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
1>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ)
1>dcmdata.lib(dcuid.obj) : error LNK2019: unresolved external symbol _Netbios@4 referenced in function "unsigned char * __cdecl getMACAddress(unsigned char * const)" (?getMACAddress@@YAPAEQAE@Z)
1>C:\Documents and Settings\yyqi\My Documents\Visual Studio 2005\Projects\try1\Debug\try1.exe : fatal error LNK1120: 5 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\yyqi\My Documents\Visual Studio 2005\Projects\try1\try1\Debug\BuildLog.htm"
1>try1 - 6 error(s), 13 warning(s)

What can I do then?
:(

Thank you.

vyrus
Posts: 19
Joined: Sat, 2006-01-21, 22:14

#5 Post by vyrus »

You also need to add netapi32.lib wsock32.lib

whqyy
Posts: 11
Joined: Fri, 2006-02-10, 09:46

#6 Post by whqyy »

It works。
Thank you for your help。
:D

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest