Skip to content

Conversation

@autoantwort
Copy link
Contributor

Or are they somehow required?

@ChristianPanov
Copy link
Owner

I've made it static because it makes more sense given the library's purpose and design. It’s fairly small and heavily relies on templates, so most of the work is done at compile time. With a static library, all the templates are resolved when you build your project, which means there’s no extra overhead at runtime, you get the benefit of no runtime indirection, such as resolving symbols from a dynamic library.

Sure, you could argue that it will be most sensible to allow the user to choose whether it is built as a static lib or dynamic lib, but that carries it's negatives. It means increased maintenance. Bugs might surface only in one version, requiring additional effort to debug and fix. Build configurations can become more complex. For example, you may need separate CMake options, different installation procedures, and separate considerations for things like symbol visibility in dynamic libraries.
Also, the library being template-heavy introduces its own challenges if its a shared library. Templates are instantiated at compile time, so users of the dynamic library would only have access to explicitly instantiated templates or would need headers anyway, which in a way reduces the value of the dynamic library. This will be hell because I will most likely need to completely rethink some of the decisions I've made regarding the templates.

If there is another point of view that I'm missing(very likely), I'll be glad to hear it. Because I am certainly biased by my own use cases and it's likely there is something I'm not taking into account.

@Minimonium
Copy link

Hi, @ChristianPanov

I know the MR is very old, but seeing it still being open and the discussion not being resolved I feel the need to drop a comment by to clear up some things.

I think there is some misunderstanding with relation to template code and static/dynamic library type. For non-plugin use there is just no difference as templated code is instantiated on a per TU basis.

For dynamic library support, there are some considerations, but CMake handles pretty much everything out of the box these days. For additional options, users can pass them in a toolchain file themselves without additional effort from you.

The fact is, you have such a small and irrelevant binary part that you may better think about making your library a header-only one. There are issues with forcing a static library if it's used by multiple shared libraries. We may say that users should just use everything as a static library, but it's not always possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants