[Mono-dev] Library path bug in Makefile?

Edward Ned Harvey (mono) edward.harvey.mono at clevertrove.com
Wed Mar 5 14:31:07 UTC 2014

> From: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-
> bounces at lists.ximian.com] On Behalf Of "Andrés G. Aragoneses"
> Right, LD_LIBRARY_PATH may be simply a fallback. But the thing is, you
> don't need LD_LIBRARY_PATH when installing libs in standard prefixes
> like /usr or /usr/local, so as you mention that LD_LIBRARY_PATH is
> empty, maybe what happens is that PATH is checked before

No, that's incorrect.  PATH is not checked for libraries.  Only the paths hard-coded into the binaries are checked, and if specified, LD_LIBRARY_PATH which generally should not be specified, because it's unnecessary when your binaries are properly linked.

Here, let me try to explain this way:

ldd /usr/local/mono-3.2.8/bin/mono
        linux-vdso.so.1 =>  (0x00007fffed3ff000)
        libm.so.6 => /lib64/libm.so.6 (0x0000003a0f200000)
        librt.so.1 => /lib64/librt.so.1 (0x0000003a0ee00000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000003a0e200000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003a0ea00000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003a0e600000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003a0de00000)

As you can see, the above mono binary was build with --prefix=/usr/local/mono-3.2.8
And as you can see, during build, the binary was linked against /lib64 and nothing else.

No other path will be checked for libraries.  It is guaranteed to fail.  Even if I had specified no prefix (or --prefix=/usr/local) then it would still be guaranteed to fail, because that would NOT populate /lib64.

Given that in this build, --prefix=/usr/local/mono-3.2.8 was specified...  The mono binary should be linked with /usr/local/mono-3.2.8/lib 

It is a safe conclusion to draw, that *whatever* is specified by --libdir=DIR, the binary should be linked against libraries in that directory.  (If not specified, libdir is derived from --exec-prefix=EPREFIX, which is derived from --prefix=PREFIX) 

More information about the Mono-devel-list mailing list