Linker error when rebuilding C++-CLI project std::basic_string
I'm writing a C++ application in Visual Studio 2008. I've added a Windows Form to my project, enabled CLR support and added a line to instantiate the form.
Since doing this, I get a load of linker errors as follows:
error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ... " (...)
Any ideas what I'm doing wrong?
Full error (anonymised):
1>Linking...
1> Creating library C:\***.lib and object C:\***.exp
1>getProducts.obj : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ***::GetClassName(void)const " (?GetClassName@***@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>getProducts.obj : error LNK2001: unresolved external 开发者_如何学Pythonsymbol "protected: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ***::GetClassName(void)const " (?GetClassName@***@@MBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>getProducts.obj : error LNK2001: unresolved external symbol "protected: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ***::GetClassName(void)const " (?GetClassName@***@@MBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>getProducts.obj : error LNK2001: unresolved external symbol "protected: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ***::GetClassName(void)const " (?GetClassName@***@@MBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>getProducts.obj : error LNK2001: unresolved external symbol "protected: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ***::GetClassName(void)const " (?GetClassName@***@@MBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>getProducts.obj : error LNK2001: unresolved external symbol "protected: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ***::GetClassName(void)const " (?GetClassName@***@@MBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>getProducts.obj : error LNK2001: unresolved external symbol "protected: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ***::GetClassName(void)const " (?GetClassName@***@@MBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>getProducts.obj : error LNK2001: unresolved external symbol "protected: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall ***::GetClassName(void)const " (?GetClassName@***@@MBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
1>MSVCRT.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\***.exe : fatal error LNK1120: 9 unresolved externals
1>Build log was saved at "file://c:\***\BuildLog.htm"
1>getProducts - 10 error(s), 12 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========
If you are using multiple user created files in your project, the error may occur because you are not declaring variables as extern or are including header files more than once. See the following website for the answer to your problem:
www.gamedev.net/page/resources/_/technical/general-programming/organizing-code-files-in-c-and-c-r1798
精彩评论