VC9 and VC8 lib compatibility

纵然是瞬间 提交于 2019-12-14 03:42:08

问题


(The original question was asked there : http://www.ogre3d.org/phpBB2/viewtopic.php?t=44832 )

Someone asked : "While I would like to build everything in vs2008 (VC9), the PhysX SDK is built with vs2005 (VC8). Would this cause any problems, using all vc9 compiled libs and used in combination with this vc8 lib?"

I answered that the day before i tried to use a .lib file (and a .dll) generated with VC8 and include it in a vc9 compiled exe, the compiler couldn't open the .lib file.

Now, other answered they did this with no problems....

I can't find the information about lib compatibility between vc9 and vc8.

so... Help?


回答1:


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.




回答2:


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() )
 }


来源:https://stackoverflow.com/questions/171816/vc9-and-vc8-lib-compatibility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!