Using .lib and .dll in D applications
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 19 11:00:07 PDT 2016
On Sunday, 19 June 2016 at 17:33:43 UTC, moe wrote:
> Unfortunatelly I still don't get it. I would like to have an
> independant project "dbar". The created lib is then used in
> another project "dfoo". Assuming that "dfoo" has no access to
> "dbar" other than the .lib file.
You can't do it with only the lib file. You *need* the source
file too for the import statement. As I explained, the lib file
is used by the linker, not the compiler. The compiler needs the
source file.
>
> My folder structure is like this:
>
> -dtest
> --dbar
> ----source\barlib.d
> ----dub.json
> This project creates a dbar.lib file which seams to work.
>
>
> -dtest
> --dfoo
> ----lib\dbar.d // copied from the dbar project
> ----source\app.d
> ----dub.json
You don't need to copy dbar to the lib directory in this case.
> This project would use the dbar.lib but should otherwise not
> have access to the dbar project. Basically simulating, that
> someone else made a dbar project to which I would not have
> access other than using the dbar.lib. How do I have to
> configure the dub.json file for this to work?
One of two things would happen:
1) They would register the project with he dub registry, then you
add a dependency to a specific version the library. Dub would
then download the necessary files for you and ensure that
everything you need is passed to the compiler when building your
project.
2) They would provide some other means for you to get the source
and the library. Then you would need to manually configure your
dub.json to pass the import path to the compiler and link with
the library.
>
> I have tried a variety of configurations for the dub.json. At
> this point it feels like a bad guessing game. That is no way to
> deveop anything. I need to figure out how to properly setup the
> dub.json but I don't seam to find the answer online.
> "http://code.dlang.org/package-format?lang=json" isn't very
> helpful.
All the information you need is there on that page.
>
> I have meanwhile adjusted my dtest/dfoo/dub.json to this:
> "dependencies": {
> "dbar": "~master"
> }
> This gives me the error: "Root package dfoo references unknown
> package dear"
As I explained above, you need a path attribute for the
dependency in this case since it is on your local file system and
not in the registry. The documentation link I gave you explains
how to to this. Try this:
"dependencies": {
"dbar": {"path": "../dbar"}
}
More information about the Digitalmars-d-learn
mailing list