I recently created a static C++ library in Visual Studio 2008.
In this project i used some methods of the std::string
class.
Now i want to use this library in a Visual Studio 2013 project.
The problem is:
Both Visual Studio versions use different platform toolsets and the project will not compile because of linker errors like:
Error 4 error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string,class std::allocator >::basic_string,class std::allocator >(void)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ)
Is there any way to make a library compatible with all platform toolsets and using some standard classes like std::string
?
FYI: VS2008 is using v90 platform toolset and VS2013 is using v120 platform toolset.
Thanks.
Edit:
If i use some standard methods in the library like std::vector
, i can't implement the library anymore.
This works:
unsigned int TestClass::TestMethod()
{
return 2;
}
This doesn't:
unsigned int TestClass::TestMethod()
{
std::vector<unsigned char> vtest;
vtest.push_back(0xff);
return 2;
}
Error:
Error 1 error LNK2019: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ) referenced in function "public: class std::basic_string,class std::allocator > & __thiscall std::basic_string,class std::allocator >::assign(class std::basic_string,class std::allocator > const &,unsigned int,unsigned int)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@ABV12@II@Z)
RT lib is set to /MT and whloe program optimization is disabled (/GL).
Is there any way to fix this?
Thanks.