How to build a static lib properly?
ryuukk_
ryuukk.dev at gmail.com
Mon Mar 6 02:09:23 UTC 2023
On Monday, 6 March 2023 at 02:00:16 UTC, Mike Parker wrote:
> 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.
This is a bug in DCD in my book
Let's take this example:
Let's pretend Mr A is a developer of a widely used Editor
"A: let's build this tool D people use to get code completion, so
we can support D"
"A: git clone dcd"
"A: let's install D so we can build it"
"A: dub build -c library"
"A: sweet a dcd.lib file"
"A: feed it into my ABC language compiler"
"A: hmm i am getting unresolved symbols, i thought i compiled a
static library of that project"
"A: sorry guys, no D support, that's what their build too gave me
but it doesn't work"
"D people: yeah sorry it doesn't give you a static library of the
project, you need to individually compile each dependencies it
uses, some are in the project directory, some are referenced as a
DUB package so you need to lookup for the source, close it and
compile it individually too, then you need to do that recursively
for each dependencies each project will use"
dub should build a static library for the project i build, that
includes each library it uses that are referenced as "library"
since the default is "staticLibrary" according to rikki
More information about the Digitalmars-d-learn
mailing list