FIX: Cannot Create bad_typeid Object with /MD (200495)



The information in this article applies to:

  • The Standard C++ Library, when used with:
    • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
    • Microsoft Visual C++, 32-bit Professional Edition 5.0

This article was previously published under Q200495

SYMPTOMS

If you try to create an object of type bad_typeid in an application built with the DLL version of the C run-time library (/MD ), you get the following link errors:

error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall std::bad_typeid::~bad_typeid(void)" (__imp_??1bad_typeid@std@@UAE@XZ)

error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::bad_typeid::bad_typeid(char const *)" (__imp_??0bad_typeid@std@@QAE@PBD@Z)

RESOLUTION

Link with any of the the static versions of the C run-time library (/MT or /ML).

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was corrected in Microsoft Visual C++ version 6.0.

MORE INFORMATION

The following sample program demonstrates the problem:
    //Sample.cpp
    //Compile options :  /MD
    #include <typeinfo>
    using namespace std;
    int main ()
    {
        bad_typeid bid;
        return 0;
    }
				

Modification Type:MajorLast Reviewed:11/18/2003
Keywords:kbBug kbfix kbVC600fix KB200495