February 23, 2005
It's currently a bit awkward to use D libraries with dmd on linux. Say I have a library called libmylib.a which is made with D. To compile the program 'myprog' you would expect that

dmd -L-lmylib myprog.d

would work, but it doesn't. It produces

gcc myprog.o -o myprog -lphobos -lpthread -lm -Xlinker -lmylib

but since parameter order matters when linking with gcc, this won't link since mylib depends on phobos. The correct place for the '-lmylib' parameter would be between '-o myprog' and '-lphobos'.

So, Walter, can you please oh please make a -l switch which puts the library parameter to gcc in the correct place? :)

(I know a workaround is to write dmd myprog -L-lmylib -L-lphobos, but in some cases you would have to add pthread and m as well. And besides, "-L-l" looks a bit clumsy, doesn't it?)

Nick


February 23, 2005
Nick wrote:

> (I know a workaround is to write dmd myprog -L-lmylib -L-lphobos,

you should also be able to use: dmd myprog.d libmylib.a ?

> And besides, "-L-l" looks a bit clumsy, doesn't it?)

Not as a clumsy as "-L-L/home/yourname/dmd/lib"... :-)

--anders
February 23, 2005
On Wed, 23 Feb 2005 14:29:54 +0100, Anders F Björklund <afb@algonet.se> wrote:

> Nick wrote:
>
>> (I know a workaround is to write dmd myprog -L-lmylib -L-lphobos,
>
> you should also be able to use: dmd myprog.d libmylib.a ?
>
>> And besides, "-L-l" looks a bit clumsy, doesn't it?)
>
> Not as a clumsy as "-L-L/home/yourname/dmd/lib"... :-)
>
> --anders

Ah... So that's how you do it... Used dmd for a crypto practical at uni today but couldn't get dmd to pass phobos location to the linker... Never would have guessed -L-L~/dmd/lib

btw - the linux installation page (http://www.digitalmars.com/d/dcompiler.html) tells me to copy libphobos.a to /usr/lib and dmd.conf to /etc - I certainly don't have write access to these at uni, so would it be worth mentioning alternatives?

As it was I ended up compiling with -c and adding a manual link step into my Makefile.

btw: D was a complete success for my practical - implemented Linear Feedback Shift Register class much faster than those struggling with C++ and with less code

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
February 23, 2005
Alex Stevenson wrote:

> Ah... So that's how you do it... Used dmd for a crypto practical at uni  today but couldn't get dmd to pass phobos location to the linker... Never  would have guessed -L-L~/dmd/lib
> 
> btw - the linux installation page  (http://www.digitalmars.com/d/dcompiler.html) tells me to copy libphobos.a  to /usr/lib and dmd.conf to /etc - I certainly don't have write access to  these at uni, so would it be worth mentioning alternatives?

I wrote it up at:
http://www.prowiki.org/wiki4d/wiki.cgi?D__Tutorial/InstallingDCompiler

--anders
February 23, 2005
On Wed, 23 Feb 2005 19:07:19 +0100, Anders F Björklund <afb@algonet.se> wrote:

Ah, cheers. Maybe one day I'll learn to check the 'usual' sources of information before doing a random hack of my own...
February 23, 2005
Alex Stevenson wrote:

> Ah, cheers. Maybe one day I'll learn to check the 'usual' sources of  information before doing a random hack of my own...

I just wrote it the other day... Maybe one day it'll find its way
onto the offical webpages as well as the user-contributed Wiki4D ?

--anders
February 23, 2005
In article <opsmnwezzb08qma6@mjolnir.spamnet.local>, Alex Stevenson says...

>Ah... So that's how you do it... Used dmd for a crypto practical at uni today but couldn't get dmd to pass phobos location to the linker... Never would have guessed -L-L~/dmd/lib

Just as a suggestion of how to set it up: I made a shell script called 'dmd' in my own bin/ directory, which basically contains

#!/bin/bash
[set environment variables here]
$DMD_PATH/bin/dmd -I$DMD_PATH/src/phobos -I$MYINC_PATH -L-L$LIB_PATH $*

and this works great for me.

Oh and I prefer to make a symlink to libphobos.a, so I don't have to remember to copy it every time I update dmd.

Nick


Top | Discussion index | About this forum | D home