Need proper order of lib files to be mentioned

Compilation and installation of DCMTK

Moderator: Moderator Team

Message
Author
shirkaan
Posts: 23
Joined: Mon, 2011-01-17, 13:24

Need proper order of lib files to be mentioned

#1 Post by shirkaan »

i have created small program . Code is as following:

#include "dcmtk/config/osconfig.h"
#include "stdafx.h"
#include<iostream>
#include"dcmtk/dcmdata/dctk.h"

int main()
{
DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("test.dcm");
if (status.good())
{
OFString patientsName;
const DcmTagKey DCM_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;
}

i have added lib files into additional dependencies of linker in following order:

dcmimage.lib
dcmimgle.lib
dcmdata.lib
ofstd.lib
netapi32.lib

i am getting following error:

1) error C2064: term does not evaluate to a function taking 2 arguments.
2) error C2228: left of '.good' must have class/struct/union

please give me proper order of lib files. need it urgently.

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#2 Post by Michael Onken »

Hi,

nothing to do with linker error. However, if interested, read urgently corresponding FAQ.

Remove the line

Code: Select all

 const DcmTagKey DCM_PatientsName;
Such constants are pre-defined in DCMTK. Just just DCM_PatientsName (for 3.5.4 and most of DCMTK 3.5.5), or use DCM_PatientName (for current DCMTK version) directly.


If you have more errors, please write in which lines since it makes it easier for us to understand them.

Best regards,
Michael

shirkaan
Posts: 23
Joined: Mon, 2011-01-17, 13:24

#3 Post by shirkaan »

i removed following line:
const DcmTagKey DCM_PatientsName;

now i am getting following error:



fatal error LNK1104: cannot open file 'dcmimage.lib'

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#4 Post by Michael Onken »

Hi,

your linker's library path seems not to include x:\yz...\dcmtk\lib directory of your DCMTK installation.

Best regards,
Michael

P.S: By the way, for the above program you only need ofstd.lib and dcmdata.lib; in newer dcmtk versions, add oflog.lib. Dependencies as described in the links above.

shirkaan
Posts: 23
Joined: Mon, 2011-01-17, 13:24

#5 Post by shirkaan »

i am not getting you. Where should i add path to lib??
and path for which folder??
i go through
tools -> options..-> projects & solutions -> VC++ Directories -> lib files.

I added path as:
D:\Home\Dcmtksource\dcmtk 3.5.4-win32-i386\lib

now i am getting 76 error as below:


Error 1 error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > & (__cdecl*)(class std::basic_ostream<char,struct std::char_traits<char> > &))" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 2 error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::endl(class std::basic_ostream<char,struct std::char_traits<char> > &)" (?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 3 error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 4 error LNK2005: "public: int __thiscall std::ios_base::width(int)" (?width@ios_base@std@@QAEHH@Z) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 5 error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,int)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 6 error LNK2005: "public: static bool __cdecl std::char_traits<char>::eq_int_type(int const &,int const &)" (?eq_int_type@?$char_traits@D@std@@SA_NABH0@Z) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 7 error LNK2005: "public: static int __cdecl std::char_traits<char>::eof(void)" (?eof@?$char_traits@D@std@@SAHXZ) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 8 error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 9 error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 10 error LNK2005: "public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " (?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 11 error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags@ios_base@std@@QBEHXZ) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 12 error LNK2005: "public: int __thiscall std::ios_base::width(void)const " (?width@ios_base@std@@QBEHXZ) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 13 error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 14 error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 15 error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 16 error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 17 error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 18 error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 19 error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in dcmdata.lib(dcfilefo.obj) msvcprtd.lib
Error 20 error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 21 error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 22 error LNK2005: "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register@facet@locale@std@@CAXPAV123@@Z) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 23 error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,char const *)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@PBD@Z) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 24 error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 25 error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 26 error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 27 error LNK2005: "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 28 error LNK2005: "void * __cdecl operator new[](unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??_U@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 29 error LNK2005: "struct std::_DebugHeapTag_t const & __cdecl std::_DebugHeapTag_func(void)" (?_DebugHeapTag_func@std@@YAABU_DebugHeapTag_t@1@XZ) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 30 error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 31 error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP80D.dll) libcpmtd.lib
Error 32 error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 33 error LNK2005: _malloc already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 34 error LNK2005: _free already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 35 error LNK2005: __CrtSetCheckCount already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 36 error LNK2005: "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ) already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 37 error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 38 error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 39 error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 40 error LNK2005: "public: virtual char const * __thiscall std::exception::what(void)const " (?what@exception@std@@UBEPBDXZ) already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 41 error LNK2005: "public: __thiscall std::bad_cast::bad_cast(char const *)" (??0bad_cast@std@@QAE@PBD@Z) already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 42 error LNK2005: "public: __thiscall std::bad_cast::bad_cast(class std::bad_cast const &)" (??0bad_cast@std@@QAE@ABV01@@Z) already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 43 error LNK2005: "public: virtual __thiscall std::bad_cast::~bad_cast(void)" (??1bad_cast@std@@UAE@XZ) already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 44 error LNK2005: __errno already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 45 error LNK2005: _localeconv already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 46 error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 47 error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 48 error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 49 error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 50 error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 51 error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 52 error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 53 error LNK2005: __crt_debugger_hook already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 54 error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 55 error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 56 error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 57 error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj) LIBCMTD.lib
Error 58 error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj) LIBCMTD.lib
Error 59 error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj) LIBCMTD.lib
Error 60 error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj) LIBCMTD.lib
Error 61 error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 62 error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 63 error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 64 error LNK2005: ___set_app_type already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 65 error LNK2005: _sprintf already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 66 error LNK2005: _sprintf_s already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 67 error LNK2005: _getenv already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 68 error LNK2005: __CrtDbgReportW already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Error 69 error LNK2005: __ismbblead already defined in MSVCRTD.lib(MSVCR80D.dll) LIBCMTD.lib
Warning 70 warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library dcmtk_new
Warning 71 warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library dcmtk_new
Error 72 error LNK2019: unresolved external symbol _WSACleanup@0 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ) dcmdata.lib
Error 73 error LNK2019: unresolved external symbol _gethostbyname@4 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ) dcmdata.lib
Error 74 error LNK2019: unresolved external symbol _gethostname@8 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ) dcmdata.lib
Error 75 error LNK2019: unresolved external symbol _WSAStartup@8 referenced in function "long __cdecl gethostid(void)" (?gethostid@@YAJXZ) dcmdata.lib
Error 76 error LNK2019: unresolved external symbol _Netbios@4 referenced in function "unsigned char * __cdecl getMACAddress(unsigned char * const)" (?getMACAddress@@YAPAEQAE@Z) dcmdata.lib
Error 77 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup MSVCRTD.lib
Error 78 fatal error LNK1120: 6 unresolved externals C:\Documents and Settings\shirkaan\My Documents\Visual Studio 2005\Projects\dcmtk_new\Debug\dcmtk_new.exe






Please give me the exact order of lib files also.

and thanks for immediate reply.
Waiting for your next post....

shirkaan
Posts: 23
Joined: Mon, 2011-01-17, 13:24

#6 Post by shirkaan »

Pls help me out....

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#7 Post by Michael Onken »

Hi,

time for another FAQ entry on the way to successfully compile :idea: . This will solve your duplicated symbol problem.

For the unresolved symbols, try adding libs "ws2_32 netapi32 wsock32" to your libraries as they are always needed for all network related code.

Best regards,
Michael

shirkaan
Posts: 23
Joined: Mon, 2011-01-17, 13:24

#8 Post by shirkaan »

now my linker order is :

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
odbc32.lib
odbccp32.lib
ws2_32.lib
netapi32.lib
wsock32.lib
dcmdata.lib
ofstd.lib



i am still facing same 71 error regarding msvcprtd.lib, libcpmtd.lib, LIBCMTD.lib, MSVCRTD.lib etc.

Is there any need to give path for lib folder anywhere?????

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#9 Post by Michael Onken »

Please refer to the FAQ about linking I referred to in my previous post. These errors have nothing to do with missing libraries or linker order.

Your problem is (most probably) that you have built and installed DCMTK as debug (/MTd or /MDd compiler flags) or release version (/MT or /MD) compiler flags, but changed to something different in your own project.

So, you must be sure that the above flags are 100% (!) the same in all the 3rd party libraries (DCMTK, OpenSSL, whatever you choose) and the code you are now trying to link.

Best regards,
Michael

shirkaan
Posts: 23
Joined: Mon, 2011-01-17, 13:24

#10 Post by shirkaan »

how to check whether DCMTK is in debug mode or release version????

which makefile need to be changed???? i am having makefile in most of the folders.

shirkaan
Posts: 23
Joined: Mon, 2011-01-17, 13:24

#11 Post by shirkaan »

I have changed the code generation options centrally in file dcmtk/CMakeLists.txt by replacing "/MT" with "/MD" and "/MTd" with "/MDd".
I have also run cmake.exe again.

But how to disable the use of this external libraries in CMake??
or how to to provide all external libraries (zlib, openssl etc.) in pre-compiled versions generated with "/MD" or "/MDd".?

from where i get all external libraries in pre compiled versions generated with "/MD" or "/MDd"??

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#12 Post by Michael Onken »

We do not offer pre-compiled /MD and /MDd versions of the external libraries , so you have to collect them from the internet or try to compile them yourself as we usually do, sorry...

However, check back whether you actually need them -- otherwise just disable them.

Best regards,
Michael

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

#13 Post by Jörg Riesmeier »

See first download package in the user contributions section.

shirkaan
Posts: 23
Joined: Mon, 2011-01-17, 13:24

#14 Post by shirkaan »

i opened cmake. I changed all shown lib files to 'off' option. I am getting error in following lib files:
msvcprtd.lib,
libcpmtd.lib,
LIBCMTD.lib,
MSVCRTD.lib

But in cmake i am not seeing those lib files.
I am havin following lib files in cmake:

WITH_LIBPNG.LIB
WITH_LIBTIFF.LIB
WITH_LIBXML.LIB
WITH_OPENSSL.LIB
WITH_ZLIB.LIB

i have disabled them, but stil getting errors.

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#15 Post by Michael Onken »

These library errors have still to do with your /MD versus MT settings. if these are the same errors as you had before.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest