如何链接到不同的libc文件? [英] How to link to a different libc file?

查看:501
本文介绍了如何链接到不同的libc文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用我的节目一起提供的共享库,而不是使用目标系统的由于版本差异。

I want to supply the shared libraries along with my program rather than using the target system's due to version differences.

LDD 说我的程序使用这些共享库:

ldd says my program uses these shared libs:

linux-gate.so.1 =>  (0xf7ef0000)**(made by kernel)**  
libc.so.6 => /lib32/libc.so.6 (0xf7d88000)**(libc-2.7.so)**  
/lib/ld-linux.so.2 (0xf7ef1000)**(ld-2.7.so)**

我已经成功地通过编译链接ld-xxx.so:

I have successfully linked ld-xxx.so by compiling with:

gcc -std=c99 -D_POSIX_C_SOURCE=200112L -O2 -m32 -s -Wl,-dynamic-linker,ld-2.7.so myprogram.c

但我没有设法成功链接 libc-xxx.so 。我该怎么做?

推荐答案

我发现了如何做到这一点:

I found out how to do it:

rpath的规定,其中所提供的库的位置。此文件夹应包含:libc.so.6的,libdl.so.2,libgcc_s.so.1和也许更多。请与使用strace找出哪些库的二进制文件使用。

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是所提供的链接

ld.so is the provided linker

GCC -Xlinker -rpath = /默认/路径/要/库-Xlinker -I /默认/路径/要/库/ ld.so program.c

gcc -Xlinker -rpath=/default/path/to/libraries -Xlinker -I/default/path/to/libraries/ld.so program.c

这篇关于如何链接到不同的libc文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆