digitalmars.D.learn - [linux, ubuntu] personal D module not found in the same directory
- le TeXnicien de surface (35/35) Jun 26 2012 hello all
- Jesse Phillips (8/17) Jun 26 2012 D uses a Compile -> link model (like most). You have hit a linker
- le TeXnicien de surface (3/24) Jun 26 2012 Thank you very much.
- Graham Fawcett (15/41) Jun 26 2012 You should also be able to do this:
- le TeXnicien de surface (3/14) Jun 26 2012 Thanks a lot. This is very interresting.
hello all I'm begining to learn to program with D. I've made this tiny module written in file truc.d <module> module truc; double carre(double x){ return x*x; } </module> and this tiny program written in file jeteste.d <prgm> import truc; // I've also tried import T = truc; import std.stdio; double cube(double x){ return x*x*x; } void main(){ double y = 5; auto z = carre(y); // alt version : // auto z = T.carre(y); writeln("vu ici ",z); } </prgm> Both files are in the same directory. I run dmd jeteste.d in the said directory and I obtain this message: jeteste.o: In function `_Dmain': jeteste.d:(.text._Dmain+0x1e): undefined reference to `_D4truc5carreFdZd' collect2: ld a retourné 1 code d'état d'exécution --- errorlevel 1 where do I err? any hint would be greatly appreciated many thanks in advance
Jun 26 2012
On Tuesday, 26 June 2012 at 16:55:56 UTC, le TeXnicien de surface wrote:and I obtain this message: jeteste.o: In function `_Dmain': jeteste.d:(.text._Dmain+0x1e): undefined reference to `_D4truc5carreFdZd' collect2: ld a retourné 1 code d'état d'exécution --- errorlevel 1 where do I err? any hint would be greatly appreciated many thanks in advanceD uses a Compile -> link model (like most). You have hit a linker error, it can not link to an object you haven't given. But on that the compiler only compiled one file. dmd allFiles.d Of.d theProject.d This will compile the files and pass them to the linker. You can learn about linking to find out how to handle libraries.
Jun 26 2012
On Tuesday, 26 June 2012 at 17:14:07 UTC, Jesse Phillips wrote:On Tuesday, 26 June 2012 at 16:55:56 UTC, le TeXnicien de surface wrote:Thank you very much. I really was at my wit's end :(and I obtain this message: jeteste.o: In function `_Dmain': jeteste.d:(.text._Dmain+0x1e): undefined reference to `_D4truc5carreFdZd' collect2: ld a retourné 1 code d'état d'exécution --- errorlevel 1 where do I err? any hint would be greatly appreciated many thanks in advanceD uses a Compile -> link model (like most). You have hit a linker error, it can not link to an object you haven't given. But on that the compiler only compiled one file. dmd allFiles.d Of.d theProject.d This will compile the files and pass them to the linker. You can learn about linking to find out how to handle libraries.
Jun 26 2012
On Tuesday, 26 June 2012 at 17:23:58 UTC, le TeXnicien de surface wrote:On Tuesday, 26 June 2012 at 17:14:07 UTC, Jesse Phillips wrote:You should also be able to do this: rdmd --build-only jeteste.d Normally, the rdmd tool will compile and immediately execute the "jeteste" program. Rdmd is "smarter" than dmd, because it will calculate all the files that you need to compile and link. However, rdmd stores the executable in a different ("hidden") directory. (On my computer, it is storing the executable in "/tmp/.rdmd-1000/.../".) But you can call rdmd as "rdmd --build-only". This will compile the executable in the *current* directory, and will not execute it. Best, GrahamOn Tuesday, 26 June 2012 at 16:55:56 UTC, le TeXnicien de surface wrote:and I obtain this message: jeteste.o: In function `_Dmain': jeteste.d:(.text._Dmain+0x1e): undefined reference to `_D4truc5carreFdZd' collect2: ld a retourné 1 code d'état d'exécution --- errorlevel 1 where do I err? any hint would be greatly appreciated many thanks in advanceD uses a Compile -> link model (like most). You have hit a linker error, it can not link to an object you haven't given. But on that the compiler only compiled one file. dmd allFiles.d Of.d theProject.d This will compile the files and pass them to the linker. You can learn about linking to find out how to handle libraries.
Jun 26 2012
On Tuesday, 26 June 2012 at 19:50:15 UTC, Graham Fawcett wrote:You should also be able to do this: rdmd --build-only jeteste.d Normally, the rdmd tool will compile and immediately execute the "jeteste" program. Rdmd is "smarter" than dmd, because it will calculate all the files that you need to compile and link. However, rdmd stores the executable in a different ("hidden") directory. (On my computer, it is storing the executable in "/tmp/.rdmd-1000/.../".) But you can call rdmd as "rdmd --build-only". This will compile the executable in the *current* directory, and will not execute it.Thanks a lot. This is very interresting. I do learn here!
Jun 26 2012