Importing a module from another directory

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 27 18:26:49 PST 2014


On 12/28/2014 3:01 AM, Derix wrote:
> But of course ! I should have thought of this myself.
> Subsequent question though : what is the -I option for ? The dmd
> embedded help states
>
> -Ipath         where to look for imports
>
> so I'd naively think it would work too, but it yields the same
> error as above.

-I is for compile time, not link time. When the compiler is compling a 
module, the compiler searches the import path for all the imported 
modules, loads the files and parses them. This is how it knows which 
symbols are available in the module it is currently compiling.

The compiler does not automatically compile imported modules, so the -I 
switch has no impact on the linker. Any modules you actually import and 
use still need to be passed for linking in some manner, either by 
compiling all the modules at the same time, compiling each individually 
with -c, linking with a library, or linking with individual object files.


More information about the Digitalmars-d-learn mailing list