digitalmars.D - dmd -I flag - how to use?
- Steve Teale (3/3) Jun 03 2007 I am baffled. If I put my sources in d:\x, and then use:
- Frank Benoit (3/8) Jun 03 2007 you need to give the source a absolute or correct relative path.
- Steve Teale (3/12) Jun 04 2007 Ah, I see, it's not a path as suggested by --help, it's a fully qualifie...
- Daniel Keep (50/64) Jun 04 2007 I think perhaps you're misunderstanding; the help message is correct.
- gareis (8/60) Jun 04 2007 One last example:
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?
Jun 03 2007
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).
Jun 03 2007
Frank Benoit Wrote:Steve Teale schrieb: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 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).
Jun 04 2007
Steve Teale wrote:Frank Benoit Wrote: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/Steve Teale schrieb: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 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).
Jun 04 2007
Daniel Keep palsalgeI 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.dOne last example: --- // d:\x\whatever.d import foo.bar; // in d:\y\foo\bar.d --- cd d:\x dmd -Id:\y whatever.d
Jun 04 2007