-1

Update:

Thanks everyone for kindly replying. Seems I was a little bit confused. The change was to add a new member function to the base class. I just realized maybe I do need to recompile everything that depends on the dll that exporting this class, since the addresses for function names in the symbol table changed. Please confirm I'm right or wrong.

Got into a debate for this,

When there is a member function change in some base class, I only recompiled all classes derived from this base, and ran into some run time error.

On the other side of the debate, I was told instead I should recompile all the classes that "depends" on this base class.

  1. I'm not sure whether that is correct or not? Because I'm building DLLs and I always understand this dynamic link idea to be not to recompile.

  2. If it's true, I'm also wondering what kind of "dependency" here is?

This question might be asked too general, please let me know if any other details I should provide. Really need to learn about the compiling and linking stuff.

Thanks!

Derek
  • 1,085
  • 2
  • 20
  • 36

1 Answers1

1

DLLs and classes don't play well together. (Using classes inside a DLL is fine, it's when you try to export them that you have problems.)

For this reason, component/object systems (such as COM, ActiveX, CORBA) define an interface that separates the user from the implementation. If the public API for the DLL only uses pointers to a type with only pure virtual functions, then it has no layout shared between the DLL and caller.

If you try to share classes with data or inline functions, you have tight coupling and will need to recompile all users for the slightest implementation change.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • Right. Since DLLs can be compiled by a different compiler than the application, same classes may have different layouts in different compilers. – Israel Unterman Apr 23 '12 at 06:01