Benefits of exporting a class from a dll vs. static library

c++, dll

Solution

Advantages of a DLL:

- You can have multiple different exe's that access this functionality, so you will have a smaller project size overall.

- You can dynamically update your component without replacing the whole exe. If you do this though be careful that the interface remains the same.

- Sometimes like in the case of LGPL you are forced into using a DLL.

- You could have some components as C#, Python or other languages that tie into your DLL.

- You can build programs that consume your DLL that work with different versions of the DLL. For example you could check if a function exists in a certain operating system DLL and only call it if it exists, and otherwise do some other processing.

Advantages of Static library:

- You cannot have dll verisoning problems that way

- Less to distribute, you aren't forced into a full installer if you only have a small application.

- You don't have to worry about anyone else tying into your code that would have been accessible if it was a DLL.

- Easier to develop a static library as you don't need to worry about exports and imports.

- Memory management is easier.

Problem

I have a C++ class I'm writing now that will be used all over a project I'm working on. I have the option to put it in a static library, or export the class from a dll. What are the benefits/penalties for each approach. The only one I can think of is compiled code size which I don't really care about. Thanks!

Original source