vs工程链接出现error LNK2005...already defined

今天使用vs2008编译工程无错误,链接过程,出现很多这样的错误:

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 msvcprtd.lib(MSVCP90D.dll)

这个错误,提示的意思应该是标准库的类已经被定义过了,但找了半天也没发现哪里重复定义,后来发现,原来我的工程使用的是lib库,而vs2008的工程设置的代码生成方式是dll库:

在property->configure->c/c++->code generation->runtime library

将Multi-threaded Debug DLL (/MDd)

改为Multi-threaded Debug (/MTd)

原文地址:https://www.cnblogs.com/jiangwang2013/p/3696615.html