A question about error Link2005(MSDV)

Compilation and installation of DCMTK

Moderator: Moderator Team

Message
Author
colinchen
Posts: 2
Joined: Tue, 2005-01-18, 11:51
Location: Xi'an PRC

A question about error Link2005(MSDV)

#1 Post by colinchen »

I want program with DCMTK on MFC,but I encountered the error link2005. I have reference the FAQ 28 and change the project compile options,It can't work well and also has these errors:

LIBCMTD.lib(dbgheap.obj) : error LNK2005: _malloc already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _free already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(dosmap.obj) : error LNK2005: __errno already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(getenv.obj) : error LNK2005: _getenv already defined in msvcrtd.lib(MSVCRTD.dll)
msvcrtd.lib(MSVCRTD.dll) : error LNK2005: __setmbcp already defined in LIBCMTD.lib(mbctype.obj)
LINK : warning LNK4098: defaultlib "msvcrtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
LIBCMTD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/test.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

My dctk code generations option is :multithreads dll debug
the application code generations option is multithreads dll debug too.

how can I deal with this problem?

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

#2 Post by Thomas Wilkens »

Have you read also FAQ #26.

massimo
Posts: 4
Joined: Sat, 2005-03-05, 10:29

#3 Post by massimo »

I have the same link2005 error and some others too

msvcprtd.lib(MSVCP70D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in dcmdata.lib(dcfilefo.obj)
msvcprtd.lib(MSVCP70D.dll) : 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(MSVCP70D.dll) : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,char const *)" (??6std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z) already defined in dcmdata.lib(dcfilefo.obj)
msvcprtd.lib(MSVCP70D.dll) : 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)
libcpmtd.lib(locale0.obj) : error LNK2005: "public: __thiscall std::locale::locale(void)" (??0locale@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP70D.dll)
libcpmtd.lib(locale0.obj) : error LNK2005: "public: class std::locale::facet const * __thiscall std::locale::_Getfacet(unsigned int)const " (?_Getfacet@locale@std@@QBEPBVfacet@12@I@Z) already defined in msvcprtd.lib(MSVCP70D.dll)
libcpmtd.lib(locale0.obj) : error LNK2005: "public: void __thiscall std::locale::facet::_Register(void)" (?_Register@facet@locale@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP70D.dll)
libcpmtd.lib(locale0.obj) : error LNK2005: "public: __thiscall std::_Locinfo::_Locinfo(char const *)" (??0_Locinfo@std@@QAE@PBD@Z) already defined in msvcprtd.lib(MSVCP70D.dll)
libcpmtd.lib(locale0.obj) : error LNK2005: "public: __thiscall std::_Locinfo::~_Locinfo(void)" (??1_Locinfo@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP70D.dll)
libcpmtd.lib(xdebug.obj) : 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(MSVCP70D.dll)
libcpmtd.lib(xdebug.obj) : 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(MSVCP70D.dll)
libcpmtd.lib(xdebug.obj) : error LNK2005: "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z) already defined in msvcprtd.lib(MSVCP70D.dll)
libcpmtd.lib(ios.obj) : error LNK2005: "public: void __thiscall std::ios_base::clear(int,bool)" (?clear@ios_base@std@@QAEXH_N@Z) already defined in msvcprtd.lib(MSVCP70D.dll)
libcpmtd.lib(ios.obj) : error LNK2005: "public: virtual __thiscall std::ios_base::~ios_base(void)" (??1ios_base@std@@UAE@XZ) already defined in msvcprtd.lib(MSVCP70D.dll)
libcpmtd.lib(ios.obj) : error LNK2005: "public: void __thiscall std::ios_base::_Addstd(void)" (?_Addstd@ios_base@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP70D.dll)

libcpmtd.lib(ios.obj) : error LNK2005: "protected: void __thiscall std::ios_base::_Init(void)" (?_Init@ios_base@std@@IAEXXZ) already defined in msvcprtd.lib(MSVCP70D.dll)
libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in msvcprtd.lib(MSVCP70D.dll)
libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP70D.dll)
libcpmtd.lib(xwctomb.obj) : error LNK2005: __Getcvt already defined in msvcprtd.lib(MSVCP70D.dll)
dcmdata.lib(dcistrmz.obj) : error LNK2019: unresolved external symbol _inflateInit2_ referenced in function "public: __thiscall DcmZLibInputFilter::DcmZLibInputFilter(void)" (??0DcmZLibInputFilter@@QAE@XZ)
dcmdata.lib(dcistrmz.obj) : error LNK2019: unresolved external symbol _inflateInit_ referenced in function "public: __thiscall DcmZLibInputFilter::DcmZLibInputFilter(void)" (??0DcmZLibInputFilter@@QAE@XZ)
dcmdata.lib(dcistrmz.obj) : error LNK2019: unresolved external symbol _inflateEnd referenced in function "public: virtual __thiscall DcmZLibInputFilter::~DcmZLibInputFilter(void)" (??1DcmZLibInputFilter@@UAE@XZ)
dcmdata.lib(dcistrmz.obj) : error LNK2019: unresolved external symbol _inflate referenced in function "private: unsigned long __thiscall DcmZLibInputFilter::decompress(void const *,unsigned long)" (?decompress@DcmZLibInputFilter@@AAEKPBXK@Z)
dcmdata.lib(dcostrmz.obj) : error LNK2019: unresolved external symbol _deflateInit2_ referenced in function "public: __thiscall DcmZLibOutputFilter::DcmZLibOutputFilter(void)" (??0DcmZLibOutputFilter@@QAE@XZ)
dcmdata.lib(dcostrmz.obj) : error LNK2019: unresolved external symbol _deflateEnd referenced in function "public: virtual __thiscall DcmZLibOutputFilter::~DcmZLibOutputFilter(void)" (??1DcmZLibOutputFilter@@UAE@XZ)
dcmdata.lib(dcostrmz.obj) : error LNK2019: unresolved external symbol _deflate referenced in function "private: unsigned long __thiscall DcmZLibOutputFilter::compress(void const *,unsigned long,bool)" (?compress@DcmZLibOutputFilter@@AAEKPBXK_N@Z)
Debug/provaDicom.exe : fatal error LNK1120: 7 unresolved externals

i think i've tried everything explained in this forum.
both my project(MFC app) and dcmtk are compiled as multithreaded dll.
If i try to remove USE_STD_CXX_INCLUDES in cfwin32.h the dcmtk can't link anymore.

my projects inker->input options are set as follows
netapi32.lib
wsock32.lib
ofstd.lib
dcmdata.lib
dcmnet.lib

is there something i am missing?
thanks

colinchen
Posts: 2
Joined: Tue, 2005-01-18, 11:51
Location: Xi'an PRC

#4 Post by colinchen »

I have solve the problem by ingore the LIBCMTD in the ingnore libriy

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

#5 Post by Thomas Wilkens »

The "unresolved external symbol" linker errors show that you apparently forgot to add "zlib_d.lib" or "zlib_o.lib" to your project settings -> linker -> input options page, i.e. you simply forgot to add a library that you are using classes/functions of. Try to get rid of these errors first, in order to make sure this works.

As for the LNK2005 error, I dont really know what causes this problem. One last thing you can try (even though Marco says in the FAQ that this should be avoided) is to add "msvcprtd.lib" to the ignore libraries section in your project settings -> linker -> input options page.

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

#6 Post by Marco Eichelberg »

Using the "ignore" option is equivalent to calling for trouble. Unless you love difficult-to-debug problems, solve the problem instead of ignoring it. The message is always caused by different parts of the program being compiled with different project settings (multithread/single thread/DLL). Locate them, fix them, and the problem should be gone.

massimo
Posts: 4
Joined: Sat, 2005-03-05, 10:29

#7 Post by massimo »

thanks to everybody,i'll try tour suggestions and let you know.
bye

massimo
Posts: 4
Joined: Sat, 2005-03-05, 10:29

#8 Post by massimo »

actually I discovered that I can't compile dcmtk.
after extacting the package, deleting dcmtk project file, reconfiguring with cmake it compiles perfectly.
but after changing flags in CmakeLists from MT to MD and from MTd to MDd to change settings to Multheaded DLL (i have to use it in mfc apps), i delete again sln and project files and reconfigure it with cmake but dcmtk can't compile anymore
these are the linker errors:

LIBCMTD.lib(dosmap.obj) : error LNK2005: __errno already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _malloc already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _realloc already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _free already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj)
LIBCMTD.lib(crt0.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(getenv.obj) : error LNK2005: _getenv already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(_ctype.obj) : error LNK2005: _isalpha already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(_ctype.obj) : error LNK2005: _isupper already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(_ctype.obj) : error LNK2005: _isdigit already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(_ctype.obj) : error LNK2005: _isspace already defined in MSVCRTD.lib(MSVCR70D.dll)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj)
LIBCMTD.lib(isctype.obj) : error LNK2005: __isctype already defined in MSVCRTD.lib(MSVCR70D.dll)
MSVCRTD.lib(MSVCR70D.dll) : error LNK2005: __close already defined in LIBCMTD.lib(close.obj)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
dcmsr.lib(dsrxmld.obj) : warning LNK4049: locally defined symbol _xmlFree imported
Debug\dsrdump.exe : fatal error LNK1169: one or more multiply defined symbols found


removing #define USE_STD_CXX_INCLUDES from cfwin32.h doesn't solve the problem.
can someone help me?i searched all the FAQ and the whole forum for an answer...
thanks

hesham
Posts: 8
Joined: Tue, 2005-08-02, 23:17

Can link with MDd but ?!!!

#9 Post by hesham »

Hi
I have the same problem like you, after working arround with CMake, I found that disbaling the use of the support libraries (zlib, xml, etc..) will correct the problem.
It seems that the support libraries need to build using the MDd option also.

I stucked with the zlib compilation, can't figure out how to comile its source under VS 2003.

Any help regarding this issue will be so much appreciated

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

#10 Post by vyrus »

But we don't always have luxury to fix the problem from scratch. I had the redefinition problem when linking against libxml. The way of ignoring LIBCMTD mentioned by colinchen becomes the only choice, since I can't recompile the libxml.

dwballance
Posts: 9
Joined: Thu, 2005-02-24, 09:15

#11 Post by dwballance »

I have successfully recompiled all the support libraries using the /MD flag. I can package them up in a zip file if Offis would like to host them somewhere, such as an alternate download to dcmtk-3.5.4-win32-i386-support.zip. (The one variation is a newer point releas of libtiff -- for some reason 3.7.4 wouldn't compile under DevStudio 2005, so I used 3.8.2.)

Let me know to whom to email the file if you are interested.

--Dennis

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

#12 Post by Marco Eichelberg »

If you could mail the package to dicom <at> offis <dot> de, we would make it available for download from our download page.

snie
Posts: 11
Joined: Tue, 2007-01-30, 20:50

Email me your zip package or tell me where to download

#13 Post by snie »

I am interested in your solution, can you email me your zip package or tell me where to download?

my email: sixiang@hawaii.edu
Thanks,

DV
________
Starcraft Ii Replay
________
OM611 ENGINE
Last edited by snie on Thu, 2011-02-17, 21:48, edited 2 times in total.

simeon
Posts: 35
Joined: Fri, 2006-09-15, 09:25
Location: Bulgaria
Contact:

#14 Post by simeon »

dwballance wrote:I have successfully recompiled all the support libraries using the /MD flag. I can package them up in a zip file if Offis would like to host them somewhere, such as an alternate download to dcmtk-3.5.4-win32-i386-support.zip. (The one variation is a newer point releas of libtiff -- for some reason 3.7.4 wouldn't compile under DevStudio 2005, so I used 3.8.2.)

Let me know to whom to email the file if you are interested.

--Dennis
Hi There's a problem with libraries in dcmtk-3.5.4-win32-i386-support.zip.

The problem is that libraries is build dynamically, but in zip file have only libs? For Instance Zlib_d.lib is 10k.

see viewtopic.php?t=948

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

#15 Post by Marco Eichelberg »

You seem to be right, but this would have to be fixed by Dennis Ballance who created this package originally and should have access to the related DLLs.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest