none
Linker error 2005, libcmtd.lib and msvcrtd.lib(MSVCR80D.dll)

    Question

  • I'm trying to port a project to VS2005 beta2 and I get lots of errors like this.

    libcmtd.lib(sprintf.obj) : error LNK2005: _sprintf already defined in msvcrtd.lib(MSVCR80D.dll)
    libcmtd.lib(swprintf.obj) : error LNK2005: __swprintf already defined in msvcrtd.lib(MSVCR80D.dll)
    libcmtd.lib(dbgheap.obj) : error LNK2005: _malloc already defined in msvcrtd.lib(MSVCR80D.dll)
    libcmtd.lib(dbgheap.obj) : error LNK2005: _free already defined in msvcrtd.lib(MSVCR80D.dll)

    Can anyone point me in the direction of fixing this?
    If its related to project properties can you specify which ones would cause it.

    Thanks.
    Jon
    Wednesday, July 27, 2005 3:37 AM

Answers

  • You have another library (old lib file) included that just supports only VC6, VC7.x.
    So the stuff you compiled is trying to use the CRT of VC8. The old stuff is using the libraries from the headers it was compiled with.
    Wednesday, July 27, 2005 12:05 PM

All replies

  • You have another library (old lib file) included that just supports only VC6, VC7.x.
    So the stuff you compiled is trying to use the CRT of VC8. The old stuff is using the libraries from the headers it was compiled with.
    Wednesday, July 27, 2005 12:05 PM
  • I get this pestilence a lot. Look at the knowledge base article Q148652 for some clues.

     - Waldemar
    Friday, August 05, 2005 6:00 AM
  • Today I also had this problem.
    It was solved by setting the "Configuration Properties" / "C/C++" / "Code Generation" / "Runtime Library" property to "Multi-threaded Debug (/MTd)".
    (The previous value of this property was "Multi-threaded Debug DLL (/MTd)".)
    Maybe this can help to others as well.
    Thursday, April 12, 2007 11:39 AM
  • I also had this problem but mine was set to "Multi-threaded Debug(/MTd)" and changing it to "Multi-threaded Debug DLL (/MTD)" solved this
    Monday, November 19, 2007 5:59 PM
  • I've same problem. If I set "Multi-threaded Debug DLL (/MTD)", there are similar problems with nafxcwd.lib.
    Friday, July 18, 2008 5:47 AM
  • Hi,

    Similar problems have occurred many time in my projects. If you have to use the library libcmtd.lib and you cannot fix the error in any other way, you can just add "/FORCE:MULTIPLE" to the linker command line in your project property.

    However, note that, this linker selection won't work correctly every time. It may incur unexpected runtime performance, since it will just choose the first implementation of the function and desert another, though it always work well in my projects.

    Tuesday, July 22, 2008 4:12 AM
  • project properties-> linker-> input-> ignore specified library : msvcrtd.lib

    Hopes it helps

    Tuesday, July 22, 2008 8:18 AM
  • Using /FORCE:MULTIPLE and /NODEFAULTLIB is almost always a bad idea. It may work for some of the most simple cases, but will fail in much worse ways for the vast majority of real-world programs.

    The real solution is to make sure you use the same compiler toolchain with compatible settings for all contributing object files including such contained in static libraries.

    -hg
    Visual C++ Libraries Team
    Tuesday, July 22, 2008 10:15 AM
  • Grunt when u guys gonna put some sense in all the different MS dependancies. how do u expect people to use VS2010 when i cannot build and deploy VS2005 without a hustle.
    Monday, December 07, 2009 12:48 PM
  • This blonster (above) is a genius. That worked.
    Friday, May 13, 2011 10:15 PM