How to link to a different libc file?

后端 未结 2 383
故里飘歌
故里飘歌 2020-12-03 18:34

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

2条回答
  •  旧时难觅i
    2020-12-03 19:03

    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

提交回复
热议问题