October 28, 2022

On Friday, 28 October 2022 at 11:35:44 UTC, Adam D Ruppe wrote:

>

On Wednesday, 26 October 2022 at 16:20:01 UTC, DLearner wrote:

>

Wanted to use a function stored in a module outside the main source.

easiest thing to do with dub is to add it as a sourcePath or a sourceFile. Well, actually, easiest is to just copy the module right into your default src folder, but second easiest is to add the other thing as the sourcePath/sourceFile.

Messing with lib compiles and import paths rarely worth the hassle.

(and without dub btw you can make a generic lib directory, add it to your -I path, then just dmd -I/path/to/libs -i yourmainfile.d and it automatically picks up things from import paths. that's how i do it myself)

Also later i see you are using the arsd terminal.d, which you can also use through dub's dependency system by adding arsd-official:terminal to its list.

Hi

To avoid confusion:

I wanted to use (yours I think!) arsd-official:terminal, and a (near-trivial) function (call it NTF) held inside one of my own modules (call it OM), itself inside my utilities directory (call it UD).
"dependencies": { "arsd-official:terminal": "~>10.9.4" },
was set in the JSON file.
When I copied OM to the package 'source' directory, dub run executed, nothing blew up, and the whole thing went as expected.

However, going forward, I don't want copies of OM anywhere other than UD.
Doing that potentially leaves similar but non-identical copies of software around, causing problems at a later stage.

So I delected OM from the 'source' directory, and (following suggestions given earlier) reviewed my calculation of the relative path from the package directory to UD, and put the result into sourcePaths.
dub run then seemed to find OM and the NTF inside it, as got through compile to:
Target is a library. Skipping execution.

Google then gave the suggestion:
"targetType": "executable",

Took suggestion, dub run then produced:
Linking... lld-link: error: subsystem must be defined Error: linker exited with status 1

Any further suggestions gratefully received.

Comments:
I am conscious that when OM was in the 'source' directory (with app), everything 'just worked'.
Therefore, to me, if OM is somewhere else, but I provide that location to dub, everything should work exactly as before.
But that does not happen.
I also thought it strange that I had to provide the UD location as a relative rather than absolute path.

Best regards

October 28, 2022
On Friday, 28 October 2022 at 15:15:04 UTC, DLearner wrote:
> Took suggestion, dub run then produced:
> `Linking...
> lld-link: error: subsystem must be defined
> Error: linker exited with status 1`

That means the linker didn't see a `main` function. Make sure you have a `void main() {}` somewhere (and of course if you want the application to do something, make main do something)


October 29, 2022
On 29/10/2022 4:15 AM, DLearner wrote:
> However, going forward, I don't want copies of OM anywhere other than UD.

If you want your own private library on your system (that will get used a lot), you can create a package and use ``$ dub add-local .`` to add it to the available packages for lookup, without needing a version control system.

Then you just add it as a dependency on an as needed basis (use ``*`` for version should work fine).
October 28, 2022

On Friday, 28 October 2022 at 21:32:46 UTC, rikki cattermole wrote:

>

On 29/10/2022 4:15 AM, DLearner wrote:

>

However, going forward, I don't want copies of OM anywhere other than UD.

If you want your own private library on your system (that will get used a lot), you can create a package and use $ dub add-local . to add it to the available packages for lookup, without needing a version control system.

Then you just add it as a dependency on an as needed basis (use * for version should work fine).

In the end, downloaded terminal.d from GitHub, stored in directory UD.
Then within 'source' directory, following Adam D Ruppe above,
dmd -i -IC:\...\UD\ -run app

And it just worked.

No calculating relative paths, no remembering to double \.

I think DUB is a little too sophisticated for my needs.

1 2
Next ›   Last »