Search

STL code does not compile in manged C++ test project. by Alexey99

Closed
as Deferred Help for as Deferred

1
0
Sign in
to vote
Type: Bug
ID: 590287
Opened: 8/27/2010 4:33:20 PM
Access Restriction: Public
1
Workaround(s)
0
User(s) can reproduce this bug
Following code in a test project does not compile:

[TestMethod]
void test_lis()
{
    vector<int> vSeq;

    int seq[] = {7, 8, 2, 3, 4}; // 2, 3, 4
    vSeq = vector<int>(seq, seq + sizeof(seq)/sizeof(int));
    Assert::AreEqual(3, CAlgorithms::lis(vSeq), "LIS Length");
}

Error    1    error LNK2028: unresolved token (0A00010D) "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ) referenced in function "public: int const & __thiscall std::_Vector_const_iterator<class std::_Vector_val<int,class std::allocator<int> > >::operator*(void)const " (??D?$_Vector_const_iterator@V?$_Vector_val@HV?$allocator@H@std@@@std@@@std@@$$FQBEABHXZ)    D:\P\Exercises\TestAlgorithms\TestAlgorithms.obj

Error    2    error LNK2019: unresolved external symbol "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ) referenced in function "public: int const & __thiscall std::_Vector_const_iterator<class std::_Vector_val<int,class std::allocator<int> > >::operator*(void)const " (??D?$_Vector_const_iterator@V?$_Vector_val@HV?$allocator@H@std@@@std@@@std@@$$FQBEABHXZ)    D:\P\Exercises\TestAlgorithms\TestAlgorithms.obj

Error    3    error LNK1120: 2 unresolved externals    D:\P\Exercises\Debug\DefaultTest.dll    1


vs. similar code that does compile:

[TestMethod]
void test_lis()
{
    //vector<int> vSeq;

    int seq[] = {7, 8, 2, 3, 4}; // 2, 3, 4
    vector<int> vSeq = vector<int>(seq, seq + sizeof(seq)/sizeof(int));
    Assert::AreEqual(3, CAlgorithms::lis(vSeq), "LIS Length");
}
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

 

Steps to reproduce

1. Create a C++ test project and use /clr setting.
2. Add test method above.

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

Test method above compiles successfully.

Expected results

Error    1    error LNK2028: unresolved token (0A00010D) "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ) referenced in function "public: int const & __thiscall std::_Vector_const_iterator<class std::_Vector_val<int,class std::allocator<int> > >::operator*(void)const " (??D?$_Vector_const_iterator@V?$_Vector_val@HV?$allocator@H@std@@@std@@@std@@$$FQBEABHXZ)    D:\P\Exercises\TestAlgorithms\TestAlgorithms.obj

Error    2    error LNK2019: unresolved external symbol "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ) referenced in function "public: int const & __thiscall std::_Vector_const_iterator<class std::_Vector_val<int,class std::allocator<int> > >::operator*(void)const " (??D?$_Vector_const_iterator@V?$_Vector_val@HV?$allocator@H@std@@@std@@@std@@$$FQBEABHXZ)    D:\P\Exercises\TestAlgorithms\TestAlgorithms.obj

Error    3    error LNK1120: 2 unresolved externals    D:\P\Exercises\Debug\DefaultTest.dll    1
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 9/22/2010 at 4:30 PM
Hi,

Thanks for reporting this issue. We have been able to reproduce it and we are investigating it. It turns out that its not STL, rather this is an IDE issue for Test Projects. The IDE is supposed to set /MDd switch by default for Debug configurations which is not happening here. While we look into this further, you can unblock your work by manually setting the runtime library option to use /MDd.

<Project properties>
C/C++ --> Code Generation --> Runtime Library = "Multi-threaded Debug DLL (/MDd)".

We will update you with more details about this issues resolution timeframe soon.

Feel free to email me at mohammad.usman@microsoft.com if you have any questions/concerns.

Mohammad Usman
Visual C++ Libraries Team
Posted by Microsoft on 8/27/2010 at 5:03 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Viorel_ on 8/28/2010 at 2:10 AM
If the problem occurs in Debug mode, then change the project's property "C/C++ --> Code Generation --> Runtime Library" to "Multi-threaded Debug DLL (/MDd)".