We just had an interesting experience in trying to link a set of code compiled using Visual Studio Express 2008 with .lib compiled with Visual Studio 2003. Everything in C ++. To be precise, it was the SystemC 2.2.0 kernel that was compiled in VS2003 into .lib, and the SystemC model that was compiled into VS2008.
When linking, we continued to get the error that several characters from the SystemC.lib file (i.e., compiled in VS2003) were not found during linking. The error we get was this (in several ways):
SystemC.lib(sc_port.obj) : error LNK2001: unresolved external symbol "public: vo id __thiscall std::_String_base::_Xran(void)const " ( ?_Xran@ _String_base@std @@QB EXXZ)
Digging from various potential customers, it turned out that the function that .lib expected to find is this:
Undecoration of :- " ?_Xran@ _String_base@std @@QBEXXZ" is :- "public: void __thiscall std::_String_base::_Xran(void)const "
While the library file that VS2008 was trying to link to (libcpmt.lib) used a different calling convention:
Undecoration of :- " ?_Xran@ _String_base@std @@SAXXZ" is :- "public: static void __cdecl std::_String_base::_Xran(void)"
I tried to understand why this incompatibility occurred, but in the end I gave up, recompiled the same visual studio project in VS2008 and used this SystemC.lib instead of the one from VS2003. Now everything worked perfectly.
So, the main question here is: what has changed from VS2003 to VS2008, what can cause some functions to change their calling conventions? And is there some kind of magic flag to let the linker in VS2008 use some other library, where the functions have the same calling convention as in the VS2003 compilation?
Update, summary of answers so far: it is very likely that Microsoft will change the C ++ (not C, only C ++) ABI from one major version of Visual Studio to the next. There may also be other changes to libraries that cause incompatibilities. The best advice is to recompile .lib for each version of VS. Essentially, just send it to the source for users and ask them to compile it locally using any version of VS that they installed.
The main problem was discovered with a tip in:
Please note that these questions did not answer this problem: