On Thursday, 27 October 2022 at 16:40:20 UTC, DLearner wrote:
> I'm not getting on with DUB.
Maybe fewer people use it under Windows, so Windows constructs don't get exercised so much.
Is there a non-DUB way of arranging that
import arsd.terminal;
will use that module as held on GitHub?
(DUB name: "arsd-official:terminal": "~>10.9.4").
OS: Windows 10. Compiler: DMD.
This has nothing to do with Windows. The source path error you encountered is an assertion failure that tells you what's wrong: dub does not allow you to add absolute paths to the source path. I don't know why. If you disagree, then you can file an issue in the dub github repository.
In the meantime, you'll need to work around the limitation. You could
- Add the file to your source tree
- Use a relative path in
sourcePaths
- Add arsd-official as a dub dependency
All of these would solve the problem. If you aren't going to do any of these things, then you'll need a fourth option.
The compiler (not dub) needs to know where to find imports, and the linker needs an object file to resolve symbols. So you should:
- Compile /arsd/terminal.d as a static library with ldc (named e.g., "arsd-terminal.lib") and output the library to the path where you want it (e.g., C:\libs)
- Add the parent directory of the arsd folder to your
importPaths
in dub.
- Add linker flags to your dub project to tell the compiler where to find the library
You have two options for #3. If this is the only external libs you're working with, then you can just add the full path to the library in an libs
entry:
"libs": ["C:\\libs\\arsd-terminal"]
Note that you do not add the ".lib" extension here. Dub will do that for you.
If you have multiple external libs, then it's better to add the library path like so:
"lflags": ["/LIBPATH:C:\\libs"],
"libs": ["lib1", "lib2", "lib3"]
Note that /LIBPATH
is specific to the Microsoft linker, which I assume LDC uses on Windows:
https://learn.microsoft.com/en-us/cpp/build/reference/libpath-additional-libpath?view=msvc-170
If it's using the LLVM linker, then you'll need the appropriate flag for that.
If you aren't planning to build on other platforms, then you'll want to make these dub directives platform specific, e.g., libs-windows
rather than libs
.