I am linking against a newer .lib but using an older .dll in my application. What are the possible side-effects of doing this? Shouldn’t everything work if the function prototypes are the same between the two versions? What if the newer version changes the default value of a parameter? Would that value be in the .lib or in the .dll?
Share
In C++ default values are compiled in at the call site – so the DLL or the .lib file will have nothing to do with that – changing the header would have the effect with no change in the ABI.
If the ABI in the exported functions don’t change you should be able to get away with using an older DLL with a program linked against a newer .lib, as long as the program isn’t using a new export that are in the new .lib but not in the older DLL.
Things which affect the ABI (I’m not claiming this is a comprehensive list):
The “libtool versioning system” (http://www.gnu.org/s/libtool/manual/libtool.html#Versioning) is a technique for identifying compatibility of shared libraries.
Note that if you’re not using a C calling convention (ie., the export names will be “C++ mangled”), then technically you have little control over the name being exported.
Here’s an explanation of how some Windows libraries (cygwin, pngdll) manage backward compatibility using a naming convention that follows libtool library versioning techniques. This is from a web archive of http://home.att.net/~perlspinr/libversioning.html – I’m mirroring it here: