compilation issues (dmd, rdmd, ldc2)

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Feb 21 14:03:01 PST 2016


On Sunday, 21 February 2016 at 21:51:27 UTC, kraxli wrote:
> a) doesn't work, I need to search for more information on 
> linking as I would like to understand these kind of basics in D 
> :-). The books I consulted so far (Learn D and D cookbook) did 
> not help me to understand the linking so far ...

I didn't go much into it in D Cookbook since I don't use 
libraries like this...

the easiest way IMO is to forget the -I switch exists, don't use 
it, and don't mess with .lib/.a files at all either. Just pass 
all the source files to the compiler together so like:

dmd yourprogram.d /path/to/consoled/consoled.d

and it will all just work because then the compiler knows where 
the module is (thus obviating -I) and can compile the source 
on-demand (thus skipping the library linking).


But if you don't do it this way, linking is just getting all the 
*compiled* code together, whereas the -I think is just about 
getting all the *imported source* together.

When you import something, the compiler reads the declarations 
for a module, but does not necessarily generate code for it. 
Linking links the generated code for the different modules 
together.



More information about the Digitalmars-d-learn mailing list