Andi Hellmund wrote: > Han wrote: > >> On Fri, Jan 15, 2010 at 6:21 AM, Tim Prince <n8tm@xxxxxxx> wrote: >> >> >>> Han wrote: >>> >>> >>> >>>> From what I learned (e.g. the book "An introduction to GCC" by Brian >>>> Gough), /usr/local/lib is searched _before_ /usr/lib by gcc linker for >>>> libraries. However, using ldd I can see my program always linked to >>>> the libraries from /usr/lib, even when the same library exists under >>>> both /usr/lib and /usr/local/lib. >>>> >>>> Is "/usr/local/lib" still searched before "/usr/lib" by GCC by >>>> default? If not, is there a way to force GCC to search /usr/local/lib >>>> first? >>>> >>>> >>>> >>> gcc doesn't control this. I hope you are misquoting the textbook. >>> Presumably, you are running under a shell which supports setting the search >>> order in PATH and LD_LIBRARY_PATH .... environments. In certain common linux >>> systems, the default order changes according to the path you use to login >>> (ssh, telnet, console,....). >>> >>> >>> >> it seems my shell does not have LD_LIBRARY_PATH... >> >> $ echo $LD_LIBRARY_PATH >> $ >> $ env | grep LD_LIBRARY_PATH >> $ >> >> >> > You could set the LD_LIBRARY_PATH environment variable in GNU bash via > > # export LD_LIBRARY_PATH="comma-separated-list-of-directories-to-search-in" > > The list is not comma-separated, but colon-separated! Sorry!