I want to supply the shared libraries along with my program rather than using the target system\'s due to version differences.
ldd
says my program uses
I found out how to do it:
rpath specifies where the provided libraries are located. This folder should contain: libc.so.6
, libdl.so.2
, libgcc_s.so.1
and maybe more. Check with strace to find out which libraries your binary file uses.
ld.so
is the provided linker
gcc -Xlinker -rpath=/default/path/to/libraries -Xlinker -I/default/path/to/libraries/ld.so program.c
Passing -nodefaultlibs
or -nostdlib
to gcc will tell it to not pass the default libraries as arguments to ld. You will then be able to explicitly specify the libc you want to link against. See the gcc(1)
man page for more details and caveats regarding both options.