Steve Goykovich
Steve Goykovich

Reputation: 757

Can changes to a dll be made, while keeping compatibility with pre-compiled executables?

We have a lot of executables that reference one of our dlls. We found a bug in one of our dlls and don't want to have to re-compile and redistribute all of our executables to fix it. My understanding is that dlls will keep their compatibility with their executables so long as you don't change anything in the header file. So no new class members, no new functions, etc... but a change to the logic within a function should be fine. Is this correct? If it is compiler specific, please let me know, as this may be an issue.

Upvotes: 4

Views: 483

Answers (3)

Peter Ruderman
Peter Ruderman

Reputation: 12485

This will work. As long as the interface to the DLL remains the same, older executables can load it and use it just fine. That being said, you're starting down a very dangerous road. As time goes by and you patch more and more DLLs, you may start to see strange behaviour on customer installations that is virtually impossible to diagnose. This arises from unexpected interactions between different versions of your various components. Historically, this problem was known as DLL hell.

In my opinion, it is a much better idea to rebuild, retest, and redistribute the entire application. I would even go further and suggest that you use application manifests to ensure that your executables can only work with specific versions of your DLLs. It may seem like a lot of work now, but it can really save you a lot of headaches in the future.

Upvotes: 3

AndersK
AndersK

Reputation: 36082

It depends

in theory yes, if you load the dll with with LoadLibrary and haven't changed the interface you should be fine.

If you OTOH link with the .dll file using some .lib stub there is no guarantee it will work.

That is one of the reasons why COM was invented.

Upvotes: 0

David Heffernan
David Heffernan

Reputation: 612963

Your understanding is correct. So long as you change the logic but not the interface then you will not run into compatibility issues.

Where you have to be careful is if the interface to the DLL is more than just the function signatures. For example if the original DLL accepted an int parameter but the new DLL enforced a constraint that the value of this parameter must be positive, say, then you would break old programs.

Upvotes: 7

Related Questions