Glibc 和 uClibc 在一个系统上并行运行
是否可以在一个系统上并行运行基于 glibc 和 uClibc 的应用程序?
背景:我们有基于二进制 gcc 的交叉编译器,配置为与 uClibc 链接。我们用它交叉编译了 glibc。现在我们想要构建一些应用程序,以便它们与 glibc 而不是 uClibc 链接。我们不想重建编译器。
Is it possible to have glibc and uClibc based applications running side-by-side on one system?
Background: We have binary gcc based cross-compiler configured to link with uClibc. We have cross-compiled glibc with it. Now we want to build some applications so they will link with the glibc rather than uClibc. We don't want to rebuild the compiler.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
glibc 和 uClibc 并存,一些程序链接到一个程序,而其他程序链接到另一个程序,这没有问题。但是,附加库存在问题。系统上的每个共享库都将针对 glibc 或 uClibc 构建(使用相应的标头,为标准库函数定义不同的 ABI),因此,例如,如果 glibc 程序和 uClibc 程序都需要 ncurses,则您需要构建两个版本的 ncurses,并有一种方法确保在运行时加载给定程序的正确版本。或者,您可以选择仅使用一组共享库,并为链接到其他 libc 的程序使用静态库,但您仍然需要构建 2 组库。
There's no problem with glibc and uClibc living side-by-side with some programs linking to one and other programs linking to the other. However, there is a problem with additional libraries. Each shared library on your system will be built against either glibc or uClibc (using the corresponding headers, which define distinct ABIs for the standard library functions), so for example if both a glibc program and a uClibc program need ncurses, you'll need to have two versions of ncurses built, and have a way of ensuring that the correct one for the given program gets loaded at runtime. Alternatively, you could choose to only use one set of shared libraries, and use static libraries for programs linked to the other libc, but you'd still need to build your 2 sets of libraries.
是的,这应该是完全可能的,但是您可能必须使用 LD_PRELOAD_PATH。如果您是静态链接,请更改为动态链接。
Yes, it should be perfectly possible, but you might have to play around with LD_PRELOAD_PATH. If you are linking statically, change to dynamic linking.
将它们混合在同一个 FHS 中几乎是不可能的,因为 ABI 和 include dir 不兼容。但是,您可以通过调整 ELF 中的动态链接器字段并利用 gcc/binutils 中的 sysroot 功能,将它们中的任何一个安装在目录偏移中。 Gentoo 社区[1] 正在进行一项实验,称为 Prefix/libc。
It is nearly impossible to mix them in the same FHS, as the ABI and include dir are incompatible. However, you could install either of them in an directory offset, by tweaking dynamic-linker field in ELF and exploiting sysroot feature in gcc/binutils. An on going experiment is in Gentoo community[1], known as Prefix/libc.