# ld limitations?



## xiphos (Apr 6, 2012)

Greetings,

I was attempting to install a package (Scribus, but that's irrelevant) when I started getting errors on some libraries I know were installed (Qt4, also through the ports tree).  To get right to the point it seems ld starts ignoring the hints after a while.

Two libraries, both in the same directory:

```
~> ls -l /usr/local/lib/gcc46/libgcc_s.so.1 /usr/local/lib/gcc46/libquadmath.so.0
-r--r--r--  1 root  wheel  424793 Sep  1  2011 /usr/local/lib/gcc46/libgcc_s.so.1
-rwxr-xr-x  1 root  wheel  794061 Sep  1  2011 /usr/local/lib/gcc46/libquadmath.so.0
```

The directory in question appears in the hints as reported by *ldconfig -r*:

```
> ldconfig -r
/var/run/ld-elf.so.hints:
        search directories: /lib:/usr/lib:/usr/lib/compat:/usr/local/lib:
/usr/local/lib/compat/pkg:/usr/local/lib/compat:/usr/local/lib/dovecot:
/usr/local/lib/gcc/x86_64-portbld-freebsd8.1/3.4.6:/usr/local/lib/gcc44:
/usr/local/lib/gcc46:/usr/local/lib/gegl-0.1:/usr/local/lib/graphviz:
/usr/local/lib/libxul:/usr/local/lib/mysql:/usr/local/lib/pth:/usr/local/lib/qt4
...
```
 (<cr> added by me for legibility)

and a little farther down, both files appear in the list:

```
...
        1074:-lgcc_s.1 => /usr/local/lib/gcc46/libgcc_s.so.1
        1075:-lquadmath.0 => /usr/local/lib/gcc46/libquadmath.so.0
...
```

Here's the head-scratcher: any library at or above line 1074 is found by ld without any issues:

```
> ld -lgcc_s
ld: warning: cannot find entry symbol _start; not setting start address
/lib/libc.so.7: undefined reference to `environ'
/lib/libc.so.7: undefined reference to `__progname'
```

Any library below line 1074 is not:

```
> ld -lquadmath
ld: cannot find -lquadmath
```

Even though both libgcc.so and libquadmath.so exist in the same directory, one is found and one is not, as well as any other library listed below it.  If I pass the -L flag with the appropriate directory to ld it will find the library in question, but this requires building a lot of ports manually and breaks portmaster/portupgrade.  I use Xfce, so that's a lot of ports relying on Qt4 that no longer build automagically 

Is there some limitation to ld that I should be aware of? Is it possible I misconfigured something somewhere? Is there some good, non-kludgy fix?  Thank you for your time.


----------

