[OpenIndiana-discuss] Setting LD_PRELOAD

McBofh james.c.mcpherson at gmail.com
Sun Nov 7 22:59:46 UTC 2010

On  7/11/10 11:27 PM, Paul Johnston wrote:

> Please regard this as a learning exercise for me so if I don't do
> the exactly right thing I learn a little bit each iteration :-)
> Anyway
> paulj at openindiana:~$ grep PRELOAD .bashrc
> LD_PRELOAD=/usr/lib/libCrun.so.1 /usr/local/lib/erlang/erts-
> export LD_PRELOAD
> paulj at openindiana:~$ source .bashrc
> Environment variable BINDIR is not set
> paulj at openindiana:~$ file /usr/local/lib/erlang/erts-
> /usr/local/lib/erlang/erts- ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, not stripped
> paulj at openindiana:~$ ldd /usr/local/lib/erlang/erts-
> libdl.so.1 => /lib/libdl.so.1
> libm.so.2 => /lib/libm.so.2
> libsocket.so.1 => /lib/libsocket.so.1
> libnsl.so.1 => /lib/libnsl.so.1
> libcurses.so.1 => /lib/libcurses.so.1
> libkstat.so.1 => /lib/libkstat.so.1
> libpthread.so.1 => /lib/libpthread.so.1
> libc.so.1 => /lib/libc.so.1
> libmp.so.2 => /lib/libmp.so.2
> libmd.so.1 => /lib/libmd.so.1
> Just curious why setting LD_PRELOAD for a single file complains
>about BINDIR

That's almost definitely from your erlang entry in LD_PRELOAD.

As others have mentioned, setting LD_PRELOAD in your shell is
massively deprecated - you can and will get weird results.

When you're building your utility/app/whatever, use

LDFLAGS=-R/path/to/libs:/path/to/other/libs -L/path/to/libs -L/path/to/other/libs

that way the binaries will have the right search path baked into them
at compile time, rather than you needing to hack around them with
LD_PRELOAD afterwards.

> As an aside if anyone can recommend good source/tutorial on linking
>/ compiling in c I would be very grateful.

I recommend bookmarking this collection:

OpenSolaris Software Developer Collection

and then having a read through the Linker and Libraries Guide

That will make you think of a lot of questions, soask.


More information about the OpenIndiana-discuss mailing list