VC9 and VC8 lib compatibility

耗尽温柔 提交于 2019-12-04 14:49:02

The lib format is COFF (http://msdn.microsoft.com/en-us/library/7ykb2k5f(VS.71).aspx), also COFF is used in the PE format. Thus I would expect that most if not all libraries built with vc8 to be linkable with vc9.

However I found a thread on msdn where MS seems not to guarantee that the libs compiled with VC8 will link nicely with VC9. http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/8042a534-aa8b-4f99-81ee-e5ff39ae6e69/)

Taking into account this 2 bits of info I would conclude: Although MS does not guarantee the complete 100% compatibility I would expect that in most cases linking a vc8 lib with vc9 to work.

Hope this helps. P.S. You write "the compiler couldn't open the .lib file.". The linker is the one that tries to open the libraries to be linked, not the compiler.

It works, but you get problems when sharing CRT/STL objects.

So when you do a 'new' in a vc8 library and return this to a vc9 function, which in turn deletes this object, you get an assert from delete.

 T* funcInVc8Lib()
 {
     return new T();
 }

 void funcInVC9Program()
 {
     T* p = funcInVc8Lib();
     // ...
     delete p; // it should at least assert here (in _CrtIsValidHeapPtr() )
 }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!