How to build a static lib properly?
Hipreme
msnmancini at hotmail.com
Wed Mar 8 10:49:28 UTC 2023
On Monday, 6 March 2023 at 05:59:09 UTC, Mike Parker wrote:
> On Monday, 6 March 2023 at 02:09:23 UTC, ryuukk_ wrote:
>
>>
>>
>> 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
>
> What you're asking for is a different use case. `staticLibrary`
> is for compiling a specific dub package as a static library. It
> does not imply that all of that package's dependencies should
> also be compiled into a single static library. Nor should it.
>
> You're asking for a package and its dependencies to be bundled
> for use outside of the dub ecosystem as a single static
> library. I won't say it's not a legitimate use case, it's just
> not one that dub currently supports, nor was it originally
> intended to (I wouldn't expect it to be a common one either,
> but then again common expectations are always changing).
>
> As a potential dub enhancement, e.g., `staticLibraryBundle`, I
> do agree it's worth exploring. I don't believe you can expect
> every package to "just work" in that environment. As Steve
> mentioned, there will always be link-time dependencies to any
> shared libraries on which those bundled libraries depend. And
> some packages may be set up in a way that causes issues, as
> Rikki noted when he said he had to make some tweaks on his
> successful build.
>
> But for the time being, dealing with static libraries in D is
> just the same as dealing with them in the C and C++ world. They
> always have been a PITA to deal with, and that's why the trend
> in recent years has been to move away from them. Build tools
> like dub hide them from you when used as intended. It's when
> you mix build systems that you run into trouble.
>
> Still, I suggest you send an email to social at dlang.org as part
> of the Gripes and Wishes campaign so that this gets added into
> the dataset. Anything that enhances dub's usability should be
> looked at.
Having a way to define a static library bundle is really great.
It does help a lot when you create a package where it is
initialized in non D code.
Right now, this is the third time I'm going to need it for my
engine, for MacOS I need to manually assign my dependencies, and
having only the main code as a library doesn't work for that
purpose. I have done before a simple program which executes dub
describe for taking the dependencies then I build the program as
a staticLibrary, problem is that this requires a 2-pass build and
it is not standard.
More information about the Digitalmars-d-learn
mailing list