How do I install a library?
Dennis
dkorpel at gmail.com
Fri Nov 9 00:13:11 UTC 2018
On Thursday, 8 November 2018 at 23:43:38 UTC, Murilo wrote:
> It finally worked, but I can't just compile it normally, I have
> to use dub run, I wish it were something simple that I just
> download into the folder and then use an import statement and
> then compile it like any other program. I wish it were as
> simple as using std.stdio for example.
Whenever you import a module from a folder somewhere else than
your project, you need to pass the location to the compiler with
the -I flag. The reason std.stdio works from everywhere is
because if you go to <D-installation-folder>/windows/bin/sc.ini
(assuming you use Windows and dmd), you will find:
[Environment]
DFLAGS="-I%@P%\..\..\src\phobos"
"-I%@P%\..\..\src\druntime\import"
This will add the -I flag with the phobos location by default.
If you run:
dub --verbose --force
You will see how dub invokes the compiler. If you look at the
compiler flags, you will likely find something like this:
-I..\..\..\AppData\Roaming\dub\packages\<package name>\source
What you could do is locate the package, move it to a folder of
your choice, and add an import to that location to your sc.ini.
The Gtkd UI-framework actually prescribes such a global install:
https://github.com/gtkd-developers/GtkD/wiki/Installing-on-Windows
I don't know how comfortable you are doing this, it may be easier
to just use dub like it's intended.
This could actually be a neat feature of dub: a global install of
a dependency.
More information about the Digitalmars-d-learn
mailing list