Search code examples
linuxlinkerldglibcuclibc

Specifying the dynamic linker / loader to be used when launching an executable on Linux


I have a weird Linux system where most of the software is compiled against Glibc and some others against uClibc.

Since the Linux is a standard distro when I launch and executable the standard dynamic linker is invoked (/lib/ld.so.1) from glibc.

I'm looking for a way to specify the dynamic loader before launching any executable so when I want to run software which was compiled against uClibc I can define the launching mechanism to use uClibc dynamic loader (/lib/ld-uClibc.so.0).

Any ideas?


Solution

  • I'm looking for a way to specify the dynamic loader before launching any executable so when I want to run software which was compiled against uClibc

    You should be specifying the correct dynamic loader while building against uClibc, using the linker --dynamic-linker argument. E.g.

    gcc -nostdlib -Wl,--dynamic-linker=/lib/ld-uClibc.so.0 \
       /lib/uClibc-crt1.o main.o -L/path/to/uClibc -lc