I personally have seen 2 different cases:
- As you mention, providing both static and shared for consumer purposes ( w/ hidden symbols)
- Should the static library limit the public symbols to be the same as the ones from the shared library ? While it does not really matter on Unix-like systems it is, I believe, not feasible on windows ?
- Does this mean we’ll need a suffix on the static lib or import lib on windows ?
- Where do symbols go ? If we put the suffix on the staticlib it would be ok but otherwise we might have name clashes
- What if a package manager maintainer want to install only one of the two ?
- What about dependencies of such targets ?
- Usually when building a shared lib, you want to link shared libs, and for static, link static ones
- For internal use, with full symbol visibility. In this case (I think it’s still better to decouple targets in this case)
- Needed for unit testing and benchmarking unless you embed those in your DLL (only doctest seems to make this feasible)
- This means you need to access dependencies that would be marked PRIVATE for the shared lib, but PUBLIC for the static one
And I’m pretty sure there’s more to it than the questions we raised here