开发者

question about link and include of different vers of a lib

Is it a problem if I have an executable and a library use different versions of another library.

Example:开发者_高级运维

If I have an executable: A.exe, and it basically wraps and depends on a static library A.lib

Both A.exe and A.lib need another library B.lib

If I have a situation like this:

The A.lib library includes B.lib version 1 (uses header files from this library) The A.exe executable includes B.lib version 2 The A.exe executable links against B.lib version 2

Under what conditions would this be problematic?

Thanks


If the same functions exist in both B1.Lib and B2.Lib and both are linked to A.exe you may end up with a problem. Basically if B1::fn returns different results to B2::fn and A.Lib relies on the B1 results and A.exe relies on the B2 results you have a MAJOR problem. The linker will just link to the first implementation it finds and you can't be 100% sure that will be in B1 or B2.

Realistically its far safer to re-write A.lib to use B2.lib. Failing that namespaces are your friend ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜