views:

22

answers:

3

This is probably a very stupid question. But assume that I have a DLL (test.dll), with some exports, that when built generates an import library (test.lib). I have an application TestApp that uses this DLL.

Now, if I want to change some functions' implementation in the DLL, and I keep the exports unchaged, do I need to rebuild my application that uses this DLL/import lib?

Thanks.

+3  A: 

No. You do NOT need to rebuild against the dll.

Consider that you application works on Windows XP and one day Windows 7 comes. The same application continue to work without rebuilding even though system dlls like user32.dll, kernel32.dll are updated!

Hemant
+1  A: 

no. One of the purposes of shared library (vs static library) is excactly this: as long as what the outside sees does not change (the exported definitions/functions), the aplications using it do not need recompiling.

stijn
+1  A: 

If the functions are C functions, and you do not change the definition of any structures that are being passed there is no need to rebuild the app.

If the DLL exports C++ classes, then the importing module does need to be rebuilt - Even though the method signatures do not change, C++ class exporting is leaky: When allocating space for the class, there is no defined allocator function that is exported (by default) as such the importing module has to guess how much space to allocate, before the calling the (Exported) constructor. It builds that guess by parsing the classes definition.

The unfortunate consequence of this is, even if you are careful to only change a classes implementation details - even though the method signatures will remain the same and the dll will load successfully, the app will allocate the incorrect number of bytes when creating a new instance on the heap or stack.

Chris Becke