On Wednesday, 26 October 2022 at 18:37:00 UTC, DLearner wrote:
On Wednesday, 26 October 2022 at 16:58:08 UTC, H. S. Teoh wrote:
On Wed, Oct 26, 2022 at 04:20:01PM +0000, DLearner via Digitalmars-d-learn wrote:
Hi

Never used DUB before.
Wanted to use a function stored in a module outside the main source.

Main source has `import <modulename>;`

Put a line into the JSON: `"importPaths": "C:\\Users\\..."` pointing to the directory holding the module.

`dub run` failed with `Expected JSON array, got string`.

Maybe try instead:

        "importPaths": [ "C:\\Users\\..." ]

since the error message indicates that it expects an array, not a string.


T

Thanks for this.
Following your suggestion, seems that DUB found the module (as it got through to the linking step without complaint), but then the linker failed to resolve the function name.

However, when I moved the module to the project `'source'` directory (and took out the `importPaths` JSON entry), everything worked.

But I don't really want to do this - the module is my collection of utilities, used in a variety of projects, so doesn't really belong within one specific project.

Best regards

The linker failed to resolve because it didn't include the symbols you imported.
Think of import a way to the compiler resolve the compilation.
Think of source a way to both the compiler and the linker to resolve compilation and linking.

If you give only the import path, you will need a library.

What you actually want is to put your new importPath to the JSON array `sourcePaths`


Reply via email to