Library path for compiling/linking

Vincent vince.dragonfly at
Mon Jun 16 01:33:37 PDT 2008

Does anybody know how to add library search paths to the environment for
compiling on Dragonfly without having to specify paths with -L on the
command line?

This works fine
    $ cc -Wall -g -o testrun -L/usr/pkg/lib -lxslt testrun.c
but without -L it fails
    $ cc -Wall -g -o testrun  -lxslt testrun.c
    /usr/libexec/binutils217/elf/ld: cannot find -lxslt

   $ env | grep LD_LIB

LD_LIBRARY_PATH worked for me before on NetBSD and, if I remember
correctly, Linux and FreeBSD as well.  It is still the same variable
that the man page for ld on Dragonfly still says to use.

The man page for ld also says

    The linker uses the  following  search  paths  to  locate  required
    shared libraries.

    8.  For  a  native  linker  on  an  ELF   system,   if   the   file
        /etc/  exists,  the list of directories found in that

Which, on Dragonfly, appears to actually be /etc/  Adding
paths to this file seems to work for runtime linking, but not compile

More information about the Users mailing list