Error linking with third party static library built using previous version of Visual Studio

I am working on a project that links to a third party static library (herin called EXTERNALLIB). In Visual Studio 2005, I was able to connect to EXTERNALLIB and create an executable. We are now using Visual Studio 2008 and I am getting the following error:

fatal error C1047: The object or library file EXTERNALLIB was created with an older compiler than other objects; rebuild old objects and libraries.

      

Is there a way to get the compiler to reference EXTERNALLIB correctly? I believe the problem may be related to specific calling conventions (__stdcall, __cdecl, __clrcall, __thiscall). Can I specify the correct calling convention for the old library in the new program? Is there any specific feedback I can provide to our vendor (for example using APIENTRY in the header files) so that this issue does not occur on future compiler updates?

The code is written in C ++. I don't have access to the code for EXTERNALLIB and so I can't rebuild it myself.

+2


source to share


1 answer


The problem is probably due to the fact that "the code is written in C ++". The C ++ ABI is essentially not fully defined by any standard and has been known to change from compiler to compiler. I suspect VS is trying to tell you that the ABI has changed again and that as a result it cannot link to the library directly.

This problem is often compounded by the desire to implement C ++ objects in DLLs, but thankfully you don't have this problem.



One approach to a solution that should work is to hide the published EXTERNALLIB API with a C-callable adapter and link the whole thing to the DLL. Create a skin with an older version of VS (in the worst case, a free version can still be found). Make sure only functions are displayed extern "C"

. Especially make sure no global objects are found from DLLs (although they may exist in your skin).

The best answer is to go back to the EXTERNALLIB provider and politely report the inability to link to the current VS as a bug and request a rebuilt version.

+5


source







All Articles