dub: how to reference a compiled package

BBasile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 25 20:03:15 PST 2016


On Thursday, 25 February 2016 at 12:15:42 UTC, mahdi wrote:
> Hi,
>
> Suppose I have a package `mypack` in `~/mypack`. I run `dub` 
> command on this package and have the compiled `mypack` file (OS 
> is Linux).
>
> Now I am working on my project. I know how to use the 
> source-code of `mypack` package in the project but what if I 
> only have the compiled binary? How can I reference and use the 
> modules of the compiled `mypack`?
>
> (I looked into the DUB homepage and it's Getting Started page 
> but could not find anything).

As you've been told previous you need a D interface file. But 
additionally:

The D interface file must be specified to DUB using

"sourceFiles" : ["folder/interface.di"],

either in a config or in the globals.

The binary, so either a .lib | .a or .obj | .o must be specified 
to DUB using

"DFlags" : ["folder/binary.a"],

Here again also accepted in a config or the globals.

This is because DUB doesn't consider such binary as source file 
but DMD or LDMD2 will accept them as source in the command line.

e.g the DMD equivalent for the two previous example is

DMD "sourceThis.d" "folder/interface.di" "folder/binary.a" 
-ofbin/thesoft


More information about the Digitalmars-d-learn mailing list