www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - /usr/bin/ld: cannot find -lphobos2

reply ZombineDev <petar.p.kirov gmail.com> writes:
I'm manually building dmd, druntime and phobos like so:

$ cd ~/dev/repos/dlang
$ git clone https://github.com/D-Programming-Language/dmd
$ git clone https://github.com/D-Programming-Language/druntime
$ git clone https://github.com/D-Programming-Language/phobos

$ cd dmd && make -f make -f posix.mak -j4 AUTO_BOOTSTRAP=1
$ cd ../druntime && make -f make -f posix.mak -j4
$ cd ../phobos && make -f make -f posix.mak -j4

$ cat << EOF > ~/dev/repos/dlang/dmd/src/dmd.conf
[Environment]

DFLAGS=-I~/dev/repos/dlang/druntime/import 
-I~/dev/repos/dlang/phobos 
-L-L/home/zombinedev/dev/repos/dlang/phobos/generated/*/release/64
EOF


$ sudo ln -s ~/dev/repos/dlang/dmd/src/dmd /bin/dmd

When my I build my library with dub I can see that dmd.conf is 
detected correctly:
$ cd $myproj

(I added the following to my dub.sdl:
dflags "-v"
lflags "-v")

$ dmd test --verbose
...
Performing "unittest" build using dmd for x86_64.
...
binary    dmd
version   v2.070-devel-46cc1c6
config    /home/zombinedev/dev/repos/dlang/dmd/src/dmd.conf
...
Linking...
...
/usr/bin/ld {other stuff...} 
-L/home/zombinedev/dev/repos/dlang/phobos/generated/*/release/64 
-lphobos2
/usr/bin/ld: cannot find -lphobos2

However
$ ls 
/home/zombinedev/dev/repos/dlang/phobos/generated/*/release/64
etc  libphobos2.a  libphobos2.so  libphobos2.so.0.70  
libphobos2.so.0.70.0  libphobos2.so.0.70.o

Any idea what I'm doing wrong?
Mar 21 2016
parent reply ag0aep6g <anonymous example.com> writes:
On 21.03.2016 11:19, ZombineDev wrote:

 DFLAGS=-I~/dev/repos/dlang/druntime/import -I~/dev/repos/dlang/phobos
 -L-L/home/zombinedev/dev/repos/dlang/phobos/generated/*/release/64
[...]
 Linking...
 ...
 /usr/bin/ld {other stuff...}
 -L/home/zombinedev/dev/repos/dlang/phobos/generated/*/release/64 -lphobos2
 /usr/bin/ld: cannot find -lphobos2

 However
 $ ls /home/zombinedev/dev/repos/dlang/phobos/generated/*/release/64
 etc  libphobos2.a  libphobos2.so  libphobos2.so.0.70
 libphobos2.so.0.70.0  libphobos2.so.0.70.o

 Any idea what I'm doing wrong?
Asterisk expansion is a shell feature. dmd probably doesn't go through a shell when running ld. Even if it did, no expansion would be done there, because the word is looked at as a whole. With the leading "-L", the pattern doesn't match an actual path. For example, compare `echo /*` with `echo -L/*`. You have to spell the different paths out.
Mar 21 2016
parent ZombineDev <petar.p.kirov gmail.com> writes:
On Monday, 21 March 2016 at 10:46:27 UTC, ag0aep6g wrote:
 On 21.03.2016 11:19, ZombineDev wrote:

 DFLAGS=-I~/dev/repos/dlang/druntime/import 
 -I~/dev/repos/dlang/phobos
 -L-L/home/zombinedev/dev/repos/dlang/phobos/generated/*/release/64
[...]
 Linking...
 ...
 /usr/bin/ld {other stuff...}
 -L/home/zombinedev/dev/repos/dlang/phobos/generated/*/release/64 -lphobos2
 /usr/bin/ld: cannot find -lphobos2

 However
 $ ls 
 /home/zombinedev/dev/repos/dlang/phobos/generated/*/release/64
 etc  libphobos2.a  libphobos2.so  libphobos2.so.0.70
 libphobos2.so.0.70.0  libphobos2.so.0.70.o

 Any idea what I'm doing wrong?
Asterisk expansion is a shell feature. dmd probably doesn't go through a shell when running ld. Even if it did, no expansion would be done there, because the word is looked at as a whole. With the leading "-L", the pattern doesn't match an actual path. For example, compare `echo /*` with `echo -L/*`. You have to spell the different paths out.
Thanks a lot! I replaced "*" with the name of my OS and it all works! I thought that if it could replace $HOME, it ought to replace the asterisk. Probably I should add this caveat to http://wiki.dlang.org/Starting_as_a_Contributor#Running_Independent_Programs for future reference.
Mar 21 2016