dmd -I flag - how to use?
Daniel Keep
daniel.keep.lists at gmail.com
Mon Jun 4 01:40:35 PDT 2007
Steve Teale wrote:
> Frank Benoit Wrote:
>
>> Steve Teale schrieb:
>>> I am baffled. If I put my sources in d:\x, and then use:
>>>
>>> dmd -c -Id:\x whatever.d
>>>
>>> the compiler says it can not find the module. How do I use -I?
>> you need to give the source a absolute or correct relative path.
>> The -I is only for imported modules (imported from within whatever.d).
>
> Ah, I see, it's not a path as suggested by --help, it's a fully qualified name, and also contrary to what it says in --help, there needs to be a space between -I and the FQN.
>
> Thanks Frank.
I think perhaps you're misunderstanding; the help message is correct.
-Ipath is for telling the compiler where to search for modules that are
imported by the program. Any arguments you specify on the command line
(outside of options) are file paths; not fully-qualified module names.
Let's say you have this:
d:\x\
foo.d
d:\y\
whatever.d -- contains "import foo;"
Let's say you open a command-prompt. Now,
cd d:\y
dmd whatever.d
will fail because the compiler won't be able to find "foo".
cd d:\y
dmd -Id:\x whatever.d
will work because now the compiler knows where to look for imported
modules. If you
cd d:\x
dmd whatever.d
This won't work because there is no file called "whatever.d" in your
current directory. Similarly,
cd d:\x
dmd -Id:\y whatever.d
Won't work because there *still* isn't a file called "whatever.d" in
your current directory; the compiler doesn't care about what paths
you've given it via -I: "whatever.d" is a relative or absolute file
path, not a fully-qualified module name.
This also works:
cd d:\
dmd -Ix y\whatever.d
However, let's say that whatever also contains "import bar;", and
"bar.d" is located in d:\y. In this case, the above would fail; you
would need to do this:
cd d:\
dmd -Ix -Iy y\whatever.d
So: recap. dmd will search for modules in your current directory and in
any directory specified by an -Ipath option. However, source modules to
compile (and libraries to link in) must be specified as file paths.
Hope that clears things up a bit.
-- Daniel
--
int getRandomNumber()
{
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}
http://xkcd.com/
v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
More information about the Digitalmars-d
mailing list