Setting import paths - project (dub) and also rdmd or dmd

David dave at
Mon Sep 19 14:24:59 UTC 2022


New to D (and enjoying the learning..) I've probably missed 
something obvious but I'm slightly confused with the best way to 
achieve a simple build.

I like to keep my reusable modules in a directory outside of the 
project directory so I can use them on another project for 

I do :-

import externalmodulename;

rdmd app.d and get a fail.

No problems, I can run rdmd thus :-


and it all compiles nicely.

Same goes for dmd just use dmd -I and it compiles the code clean.

I'd normally just have a CPPFLAGS=... line in a classic Makefile 
to do this for me but can't see a native D way of doing it.  I 
looked at dub and that that :-

dub add-path ../EXTERNALMODULES

would do the trick but it doesn't make a difference (the path is 
added to the relevant json file in ~/.dub), I also tried 
add-local but no difference.  I was expecting it to add something 
to dub.sdl but that hasn't changed since I created the project.

TLDR: How do I automatically specify the -I to the compilers so I 
don't need to specify it manually each time ?



More information about the Digitalmars-d-learn mailing list