We just had an interesting experience in trying to link a set of code compiled using Visual Studio Express 2008 with a .lib compiled with Visual Studio 2003. All in C++. To be precise, it was the SystemC 2.2.0 kernel that was compiled in VS2003 into a .lib, and a SystemC model which was compiled in VS2008.
When linking, we kept getting the error that a few symbols from the SystemC.lib file (i.e., compiled in VS2003) were not found during linking. The error we get getting was this (in a few variants):
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 on from various leads, it turned out that the function the .lib expected to find was 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 with (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 figure out why this incompatibility happened, but in the end I gave up, recompiled the exact same visual studio project in VS2008, and used that SystemC.lib instead of the one from VS2003. Now, things worked perfectly.
So the fundamental question here is: what has changed from VS2003 to VS2008 that would cause some functions to change their calling conventions? And is there some magic flag to give to the linker in VS2008 to use some other library where the functions have the same calling convention as in the VS2003 compile?
Update, summary of answers so far: It is very likely that Microsoft changes the C++ (not C, just C++) ABI from one major version of Visual Studio to the next. There can also be other changes in the libraries that cause incompatibilities. The best advice is to recompile the .lib for each version of VS. Essentially, just ship it in source to the users and have them compile it locally using whatever version of VS they happen to have installed.
The basic issue was discovered by using the advice in:
Note that these questions did not answer this issue: