digitalmars.D.learn - imports && -run [Bug?]
- Andrew Edwards (33/33) May 12 2016 module mod;
- tsbockman (10/21) May 12 2016 According to the DMD compiler manual, the -run switch only
- Andrew Edwards (10/33) May 12 2016 Thanks, I guess I just expected it to work the same as rdmd does and
- Jacob Carlborg (5/10) May 13 2016 There's no technical reason why the compiler is not doing this, as far
- Jacob Carlborg (10/18) May 12 2016 To elaborate, since the second file "inc" is not passed to the compiler,...
- zabruk70 (4/6) May 13 2016 but i should warn about annoing bug with local import
module mod; // import inc; [1] // import inc: p=print; [1] // static import inc; [1] void main() { // import inc: print; // [2] print(); // static import inc; // [3] // inc.print(); } ------------------------------ module inc; /*public*/ void print() // [4] { import std.stdio: writeln; writeln("You made it!"); } ------------------------------ compiler: DMD v2.071.0 os: OS X El Capitan (10.11.3) ------------------------------ command: dmd -run mod inc output: Undefined symbols for architecture x86_64: "_D3inc5printFZv", referenced from: __Dmain in mod.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) --- errorlevel 1 None of the variations of imports work when compiled with the -run switch but all work perfectly well without it.
May 12 2016
On Friday, 13 May 2016 at 01:16:36 UTC, Andrew Edwards wrote:command: dmd -run mod inc output: Undefined symbols for architecture x86_64: "_D3inc5printFZv", referenced from: __Dmain in mod.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) --- errorlevel 1 None of the variations of imports work when compiled with the -run switch but all work perfectly well without it.According to the DMD compiler manual, the -run switch only accepts a single source file: -run srcfile args... After the first source file, any further arguments passed to DMD will be interpreted as arguments to be passed to the program being run. Have you tried using DUB? It has lots of convenient features, including a `run` command that supports multiple source files: http://code.dlang.org/docs/commandline#run
May 12 2016
On 5/13/16 3:10 PM, tsbockman wrote:On Friday, 13 May 2016 at 01:16:36 UTC, Andrew Edwards wrote:Thanks, I guess I just expected it to work the same as rdmd does and didn't even bother trying to look in the manual regarding this. I fail to see why the compiler would be less capable at this task than rdmd. Since it is already build to accept multiple input files and knows more about what's going on during compilation than rdmd will ever know, in does not make sense that it should inferior in this regard: yet rdmd takes one imput file and sorts out all dependencies.command: dmd -run mod inc output: Undefined symbols for architecture x86_64: "_D3inc5printFZv", referenced from: __Dmain in mod.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) --- errorlevel 1 None of the variations of imports work when compiled with the -run switch but all work perfectly well without it.According to the DMD compiler manual, the -run switch only accepts a single source file: -run srcfile args... After the first source file, any further arguments passed to DMD will be interpreted as arguments to be passed to the program being run.Have you tried using DUB? It has lots of convenient features, including a `run` command that supports multiple source files: http://code.dlang.org/docs/commandline#runI've used dub before but it is not desired for what I'm trying to do. rdmd does the trick. Thank you.
May 12 2016
On 2016-05-13 08:27, Andrew Edwards wrote:I fail to see why the compiler would be less capable at this task than rdmd. Since it is already build to accept multiple input files and knows more about what's going on during compilation than rdmd will ever know, in does not make sense that it should inferior in this regard: yet rdmd takes one imput file and sorts out all dependencies.There's no technical reason why the compiler is not doing this, as far as I know. -- /Jacob Carlborg
May 13 2016
On 2016-05-13 08:10, tsbockman wrote:According to the DMD compiler manual, the -run switch only accepts a single source file: -run srcfile args... After the first source file, any further arguments passed to DMD will be interpreted as arguments to be passed to the program being run.To elaborate, since the second file "inc" is not passed to the compiler, it will not compile that file, therefore you get linker errors. The solution is to pass all extra files before the -run flag. Even better is to use "rdmd" which will automatically track and compile dependencies. Using rdmd it's enough to pass a single file to compile all dependencies and run the resulting binary: "rdmd mod".Have you tried using DUB? It has lots of convenient features, including a `run` command that supports multiple source files: http://code.dlang.org/docs/commandline#runDub is a great tool when a project grows larger than a few files. -- /Jacob Carlborg
May 12 2016
On Friday, 13 May 2016 at 06:33:40 UTC, Jacob Carlborg wrote:Even better is to use "rdmd" which will automatically track and compile dependencies.but i should warn about annoing bug with local import http://forum.dlang.org/post/mailman.1984.1373610213.13711.digitalmars-d puremagic.com https://issues.dlang.org/show_bug.cgi?id=7016
May 13 2016