0

I understand that attempting to link objects/libraries that were compiled with different Visual C++ toolset versions will result in failure as was described here error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj.

However, when working with the 2010 DirectX SDK there is seemingly no problem with linking to these old libraries (eg. d3d11.lib, etc.) even if we use VC++12/13/15.

Why is it that we can link to these old DirectX libraries but not ones created by earlier versions of VC++. Also, if not VC++, what was used to compile these DirectX libraries in the first place?

Community
  • 1
  • 1
Dominic
  • 41
  • 1
  • 1
  • 3
  • Note that with VC++12/13/15 you shouldn't be using the legacy DirectX SDK for ``d3d11.lib`` and the like. You should only be using it--if at all--for the deprecated ``d3dx11.lib`` library or down-level ``xaudio2.lib`` that works on Windows 7. See [MSDN](https://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx) and [this blog post](http://blogs.msdn.com/b/chuckw/archive/2013/07/01/where-is-the-directx-sdk-2013-edition.aspx) – Chuck Walbourn Aug 04 '15 at 20:26

1 Answers1

0

DirectX libraries are C libraries (featuring COM). C traditionally has platform-specific ABI conventions.

Your libraries/objects are C++. C++ usually has no stable ABI even within the same platform. Linking code compiled with different compilers, different versions of the same compiler, same compiler versions but with different compilation flags is not supported. Same is true for different standard libraries and standard library versions.

Microsoft usually keeps C++ binary compatibility between major versions of Visual Studio compiler. For portable code, Microsoft recommends using C or COM.

See also:

Community
  • 1
  • 1
Ivan Aksamentov - Drop
  • 12,860
  • 3
  • 34
  • 61
  • Ah, I got it, thanks! I should have spotted that the question of C vs. C++ is what makes the difference. – Dominic Aug 04 '15 at 10:50
  • C++ and C is sort of the issue, but the core of the issue is the difference between a _static library_ and an _import library_. An _import library_ is just a stub ``.lib`` that contains C ABI link stubs with all the code in the DLL. You can usually use an _import library_ built from different versions of the toolsets easily, which is why ``d3d11.lib`` works. What does not work is mixing a _static library_ between different toolsets. That is where things get messy, and when the ``detect_mismatch`` thing actually fires. – Chuck Walbourn Aug 04 '15 at 20:24