Thu Nov 26 10:22:58 CET 2009

buildroot - nonstandard location

I've constructed a root file system, and stored it under /data/root on
an Android filesystem.  Everything works fine with chroot (from a
separate statically compiled busybox in /data/bin/busybox), but I
can't seem to run /data/root/usr/bin/socat outside of the chroot.  The
/data/root/bin/busybox binary works fine as long as the following is

export PATH=/data/root/bin:/data/root/sbin:/data/root/usr/bin:/data/root/usr/sbin:/data/bin:/bin:/sbin:/usr/bin:/usr/sbin:$PATH
export LD_LIBRARY_PATH=/data/root/lib:/data/root/usr/lib

What's missing?

A hint is maybe that ssl doesn't want to use LD_LIBRARY_PATH?  In some
cases this is disabled.

The proper fix seems to be to add a linker option:

   -R '$ORIGIN/../lib:/lib:/usr/lib'

This allows myapp and mylib.so to be installed anywhere, as long as
they are kept in the same positions relative to each other.

Now, this comes from [1], solaris.  Does it work on linux too?  The
GNU ld manpage says:

  For compatibility with other ELF linkers, if the -R option is
  followed by a directory name, rather than a file name, it is treated
  as the -rpath option.

From here[2] I find this flag:


In buildroot this is the variable BR2_EXTRA_GCC_CONFIG_OPTIONS which
can be set in:

  Buildroot Configuration -> Toolchain -> Additional gcc options

However, figuring out how the different levels of quoting work is not

Wrong: these are GCC build options (for building the compiler).

Wait... Maybe an appropriately defined /etc/ld.so.conf should do it?

[1] http://blogs.sun.com/ali/entry/avoiding_ld_library_path_the
[2] http://www.scons.org/wiki/UsingOrigin