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

Reply via email to