Share via


LNK2019_unresolved external symbol __imp___CrtDbgReportW after I added a vector to my project

Question

Wednesday, June 13, 2018 5:11 PM

Full error code:Error LNK2019 unresolved external symbol __imp___CrtDbgReportW referenced in function "void * __cdecl std::_Allocate(unsigned int,unsigned int,bool)" (?_Allocate@std@@YAPAXII_N@Z)

After adding a vector to my project I got that link error. I am using "Debug" as the active config. My run time library debug configuration is set to Multi-threaded Debug DLL (/MDd). I also have a _DEBUG define in my preprocessor definitions.

All replies (4)

Wednesday, June 13, 2018 10:37 PM

Full error code:Error LNK2019 unresolved external symbol __imp___CrtDbgReportW referenced in function "void * __cdecl std::_Allocate(unsigned int,unsigned int,bool)" (?_Allocate@std@@YAPAXII_N@Z)

After adding a vector to my project I got that link error.

You neglected to provide pertinent details, such as:

Version of Visual Studio being used.

Toolset(s) specified for the project.

etc.

  • Wayne

Wednesday, June 13, 2018 10:39 PM | 1 vote

Which version of VC++ are you using?

It sounds to me like you are omitting a necessary import library from the link.  For example, in VC++ 2015 the symbol is resolved by the inclusion of ucrtd.lib


Thursday, June 14, 2018 1:17 AM

If you start of a new console application project, leave it at the default settings and use the following code:

#include <vector>

int wmain()
{
    std::vector<int> a;

    a.push_back(10);

    return 0;
}

does this build?

If it does, and you are using the same compiler toolset version as the project that is failing, then it is either the compiler or linker options that are the problem. In this case you need to state which ones you have changed from default.

The _CrtDbgReportW call is part of the _ASSERT that is in the _SCL_SECURE_ALWAYS_VALIDATE macro that is used in some versions of std::_Allocate, so this means under default settings the compiler will provide the right libraries to resolve this.

This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.


Thursday, June 28, 2018 1:52 AM

Hi,

Have you got any updates? If your case has been solved, please help to mark answers. If not, just feel free to contact us.

Your understanding and cooperation will be grateful.

Best Regards,

Baron Bi

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.