Jump to page: 1 2
Thread overview
How do I install a library?
Nov 08
Murilo
Nov 08
Murilo
Nov 08
Murilo
Nov 08
bachmeier
Nov 09
bachmeier
5 days ago
bachmeier
6 days ago
aberba
6 days ago
greatsam4sure
Nov 09
Dennis
November 08
I want to install the library DlangUI but I don't know how to do it. In python I just type pip <pckg> and it works, but in D I don't know how to do it. Can anyone help me?
November 08
On 11/8/18 4:46 PM, Murilo wrote:
> I want to install the library DlangUI but I don't know how to do it. In python I just type pip <pckg> and it works, but in D I don't know how to do it. Can anyone help me?

dlangui will be fetched if you make it a dependency of your project.

When you run dub init on your project, it will ask for dependencies, just type dlangui in there.

-Steve
November 08
On Thursday, 8 November 2018 at 22:28:38 UTC, Steven Schveighoffer wrote:
> On 11/8/18 4:46 PM, Murilo wrote:
>> I want to install the library DlangUI but I don't know how to do it. In python I just type pip <pckg> and it works, but in D I don't know how to do it. Can anyone help me?
>
> dlangui will be fetched if you make it a dependency of your project.
>
> When you run dub init on your project, it will ask for dependencies, just type dlangui in there.
>
> -Steve

Thanks, I tried that but when I add the import dlangui in the beginning it doesn't work. I wanted to just type import dlangui in the beginning of the file so I can call the dlangui functions.
November 08
On 11/8/18 5:46 PM, Murilo wrote:
> On Thursday, 8 November 2018 at 22:28:38 UTC, Steven Schveighoffer wrote:
>> On 11/8/18 4:46 PM, Murilo wrote:
>>> I want to install the library DlangUI but I don't know how to do it. In python I just type pip <pckg> and it works, but in D I don't know how to do it. Can anyone help me?
>>
>> dlangui will be fetched if you make it a dependency of your project.
>>
>> When you run dub init on your project, it will ask for dependencies, just type dlangui in there.
>>
> 
> Thanks, I tried that but when I add the import dlangui in the beginning it doesn't work. I wanted to just type import dlangui in the beginning of the file so I can call the dlangui functions.

D uses dub and code.dlang.org to fetch dependencies (similar to python or other ecosystems).

If you are using dub to build your project, just add dlangui as a dependency, and you can then import and use it. This goes in your dub.json or dub.sdl file. See documentation here: http://code.dlang.org/getting_started

If you want to build the dlangui library directly and install it on your own without dub, you would need to download the source (probably from github) and build it using dub.

-Steve
November 08
On 11/8/18 6:07 PM, Steven Schveighoffer wrote:

> If you want to build the dlangui library directly and install it on your own without dub, you would need to download the source (probably from github) and build it using dub.

When I said without using dub, I meant without using dub to build your project. You still need to use dub to build the library.

-Steve
November 08
On Thursday, 8 November 2018 at 23:28:05 UTC, Steven Schveighoffer wrote:
> On 11/8/18 6:07 PM, Steven Schveighoffer wrote:
>
>> If you want to build the dlangui library directly and install it on your own without dub, you would need to download the source (probably from github) and build it using dub.
>
> When I said without using dub, I meant without using dub to build your project. You still need to use dub to build the library.
>
> -Steve

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.
November 08
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.

Unfortunately your stuck with Dub if you want to use D. It's an awful experience compared to Python and other scripting languages, so I understand what you're saying, but most people around here think Dub is the way to go.
November 08
On 11/8/18 6:43 PM, Murilo wrote:
> On Thursday, 8 November 2018 at 23:28:05 UTC, Steven Schveighoffer wrote:
>> On 11/8/18 6:07 PM, Steven Schveighoffer wrote:
>>
>>> If you want to build the dlangui library directly and install it on your own without dub, you would need to download the source (probably from github) and build it using dub.
>>
>> When I said without using dub, I meant without using dub to build your project. You still need to use dub to build the library.
>>
> 
> 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.

It's actually not a bad idea to be able to "install" libraries like you have your compiler installed. It could be done with the infrastructure that's there already. Would be cool for playing around with toy projects without having to initialize a dub project. There is the ability to include the dub file in the source file itself, but that may be too complex for your taste.

For most people who want to have their projects depend on others, there is the need to specify the projects, how they should be built, and what versions, etc. Which is why dub is used to build most things.

-Steve
November 09
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.
November 08
On Thu, Nov 08, 2018 at 11:51:39PM +0000, bachmeier via Digitalmars-d-learn wrote:
> 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.
> 
> Unfortunately your stuck with Dub if you want to use D. It's an awful experience compared to Python and other scripting languages, so I understand what you're saying, but most people around here think Dub is the way to go.

It's not true that you're stuck with dub.  And I'm not among the people who think dub is the way to go (though it's true that that's a minority opinion around here).  Where I have a choice, my own D projects do not use dub.

I have one project that uses dub because it's based on vibe.d, but I mostly avoid needing to use dub by creating an empty dub project in a subdirectory whose sole purpose is to declare a dependency on vibe.d. Then I build that once with dub, and outside in my real project I just link directly to the produced artifacts. (The exact path(s) to the dub products can be extracted from the output of `dub -v`. This can probably be automated and translated into your build system of choice, though I haven't quite gone that far yet.)  Then I don't need to use dub except when upgrading the dub-dependent library.

I find dub almost completely unusable for normal development, because:

(1) it requires network access,

(2) it's dog-slow compared to how fast the actual D compiler runs (it
tries to do dependency updating every single time it runs, even when all
you've done is to change 1 line in your code),

(3) it either does not support incremental builds, or else is so bad at doing it that it takes about just as long as a full build from scratch;

(4) it's not configurable enough to meet my build needs -- e.g., it's completely unable to handle my current Android project that involves compiling Java code, D code, GLSL code, and cross-compiling / linking / building an APK, plus compile and link an X11 test driver on the host PC, which involves invoking a different (non-cross) compiler with different libraries and a different set of source files -- dub's build spec simply isn't capable of expressing the level of configurability required to do all of this;

(5) it imposes a source tree hierarchy that conflicts with what I need
(Android SDK's APK tools expect a particular directory structure that
does not fit into dub's model).


While I appreciate the amount of effort it took to develop and deploy dub, I am sorry to say that it falls far short of my expectations and I can't see myself using it in any meaningful sense in the foreseeable future.  Using it as a dependency puller for vibe.d is about as far as I will go, unfortunately.

Many of dub's limitations, AFAICT, are inherent to its design and architecture, so I don't see any easy way to fix these problems either, short of rewriting it from scratch (and I have no inclination to take on something that big at this time).

Atila Neves has also created his own D-based build system that reportedly is much superior to dub.  You might want to look into that as well.


T

-- 
INTEL = Only half of "intelligence".
« First   ‹ Prev
1 2