How to build a static lib properly?

Mike Parker aldacron at gmail.com
Mon Mar 6 02:00:16 UTC 2023


On Monday, 6 March 2023 at 01:52:06 UTC, ryuukk_ wrote:
6B71D90\dparse.lib -g
>> ```
>
> Are you saying dub doesn't build a static dcd.lib?
>
> What to do to make it so i get a static dcd.lib file that 
> contains all the code it needs?
>
> This comfort me in my desire to no longer use dub ever

This is not dub's fault. When building a shared library, there's 
a link step, so any external dependencies are linked into the 
shared library just as they are with an executable. There is no 
link step with a static library. That means when you build your 
executable, you need to also link the static library's 
dependencies along with it.

Most of the symbols in your list appear to come from the packages 
listed in the dependencies section of DCD's dub.json:

https://github.com/dlang-community/DCD/blob/master/dub.json

So if you want to do this manually, with DCD as a static library, 
then you also need to build all of those dependencies and link 
them with your executable.


More information about the Digitalmars-d-learn mailing list