dub can build library for dependencies

Steven Schveighoffer schveiguy at gmail.com
Mon Aug 3 20:51:36 UTC 2020


On 7/31/20 2:07 PM, zoujiaqing wrote:
> On Friday, 31 July 2020 at 03:09:03 UTC, Steven Schveighoffer wrote:
>> On 7/30/20 8:04 AM, zoujiaqing wrote:
>>> I want to rely on a library, but I don't want to compile it on my 
>>> computer. I hope dub can help us with this function.
>>
>> No it cannot.
>>
>> Every build of a library for a project has a unique set of version 
>> definitions (e.g. has_vibe_d)
>>
>> So a library built for your project may possibly be different than one 
>> built for another project.
>>
> 
> Thanks Steve! But about libphobos?
> 
> I can't compile phobos library! easy! fast!

If you compile against phobos with different versions than what it was 
compiled with, then you will have potential problems.

But Phobos also isn't meant to have dependencies on vibe or the like.

An example:

https://github.com/mysql-d/mysql-native/blob/master/source/mysql/connection.d#L446-L471

If you have a pre-compiled mysql-native app without vibe-core support 
(i.e. wasn't compiled with vibe-core also as a dependency), but then you 
compile an app and include vibe-core, your app will build, run, and 
promptly crash.

So yes, technically, you can have a library that has no other 
dependencies (because you know it doesn't), and one could compile it 
once and use it wherever.

But dub cannot be the one that decides how to do this. You have to do it 
manually.

-Steve


More information about the Digitalmars-d mailing list