title: How can windows or other system dynamic / shared libraries be linked yet VS to MinGW is incompatible?
body: <p>I am learning more about shared libraries and also linking in general, and I seem to have confused myself.</p>
  <p>I understand (correct me if i am wrong) that a compiled library or object file in c++ may not be compatible with another library even on the same target architecture, if the compilers are different and that this is due to name mangling and the Application Binary interface being different in OS/Compiler/Architecture etc.</p>
  <p>This I believe is also true for C libraries although this may have more chance to work (I am not totally sure that's right)</p>
  <p>And I believe the above applies to both static and shared/dynamic libraries</p>
  <p>But then I get very confused, because say i make a new Visual Studio VC++ project, and it will link with say kernel32.dll or Gdi32.lib, well I have no idea what these were compiled with but my guess is it wasn't VS2017's Visual C++ Compiler so how can this be linked yet I can't link to say something compiled with MinGW or maybe even something with an earlier VS release? Surely the Windows dlls have been compiled differently?</p>
  <p>I guess this also applies to linux libraries I am assuming the shared object files could have been compiled with a different version of gcc/g++, and I imaging yum installing a devel package would give libs that might not work?</p>
  <p>And finally if someone has a closed source library and sell that library if the compiler and version matters does that mean that in order to sell a DLL or SO you need to compile it for more or less every compiler and version?</p>
  <p>I have read a lot of questions and answers on here and tried to do a lot of searching but I am stuck and could really use some help in understanding this.</p>