compilation issues (dmd, rdmd, ldc2)

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Feb 21 14:53:17 PST 2016


On 21.02.2016 22:51, kraxli wrote:
> On Sunday, 21 February 2016 at 21:35:55 UTC, anonymous wrote:
[...]
>> a) do it the linker way: `dmd -L-L~/.dub/packages/consoled-1.0.0/
>> -L-lconsoled ...`, or
>> b) do it the dmd way: `dmd
>> ~/.dub/packages/consoled-1.0.0/libconsoled.a ...`.
>
> b) works! :-) Many thanks!!
> 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 investigated a bit on option a. The tilde (~) is the problem. Tilde 
expansion is only done when it's the first character of a word. So you 
either have to replace the tilde with "/home/foo", or somehow make it 
the first character of a word for the shell. Since you can't just put a 
space there, you would have to hack around a bit. For example:

     dmd -L-L`echo ~`/.dub/packages/consoled-1.0.0/ ...

Regarding learning about linking: dmd's -L flag just forwards its 
argument to the linker. The linker isn't D-specific. To learn about 
linking in D you can learn about compiling/linking in general (what's a 
compiler, what's a linker, what's an object file, etc.), and you can 
learn about the command line interface of the specific linker that dmd 
invokes.

On Ubuntu, dmd calls gcc for linking, which in turn calls ld. So if you 
want to know what to put into those -L arguments, you have to learn the 
gcc/ld command lines.


More information about the Digitalmars-d-learn mailing list