Are compiled .lib files interchangeable for different versions of Microsoft Visual C++?

前端 未结 1 571
情书的邮戳
情书的邮戳 2021-01-02 09:39

Some projects provide a single set of \"Windows\" binaries for C (and possible C++ - not sure) libraries. For example, see the links on the right side of this libxml-related

相关标签:
1条回答
  • 2021-01-02 10:08

    The MS COFF format (.lib, .obj, etc) is the same for all VC++ versions and even for other languages.

    The problem is that .obj files depend on other .obj (.lib) files.
    For C++ code, there is a happy chance that code won't compile with new version of VC++ standard library implementation. For example, an old version of CRT used extern "C++" void internal_foo(int), and newer CRT uses extern "C++" void internal_foo(int, int), so linker will fail with "unresolved external symbol" error. For C code, there is a chance that code will compile, because for extern "C", symbol names doesn't encode whole signature. But at runtime application will crash after this function will be called.
    The same thing can happen if layout of some data structure will change, linker will not detect it.

    0 讨论(0)
提交回复
热议问题