我可以在 Redhat Linux 机器上使用在 Ubuntu 上编译的共享库吗? [英] Can I use a shared library compiled on Ubuntu on a Redhat Linux machine?

查看:46
本文介绍了我可以在 Redhat Linux 机器上使用在 Ubuntu 上编译的共享库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 Ubuntu 9.10 桌面上编译了一个共享库.我想将共享库发送给拥有 Red Hat Enterprise 5 盒子的合作开发者.

I have compiled a shared library on my Ubuntu 9.10 desktop. I want to send the shared lib to a co-developer who has a Red Hat Enterprise 5 box.

他可以在他的机器上使用我的共享库吗?

Can he use my shared lib on his machine?

推荐答案

第一点:所有关于编译器版本的答案似乎都被误导了.重要的是链接(当然还有架构).

First point: all of the answers regarding compiler version seem misguided. What's important are the linkages (and the architecture, of course).

如果您将 .so 文件复制到启动系统(到它自己的 /usr/local/*/opt/*> 目录,例如)然后尝试使用 LD_PRELOAD 环境设置运行预期的可执行文件.如果链接器 (ld-linux.so) 设法解析两者之间的所有符号,则程序应该加载并运行.

If you copy the .so file over to the start system (into its own /usr/local/* or /opt/* directory, for example) then try to run the intended executable using an LD_PRELOAD environment settings. If the linker (ld-linux.so) manages to resolve all the symbols between the two then the program should load and run.

所以它应该是可能的,并且相当安全(只要您不覆盖任何现有的系统库并且只使用 LD_* /etc/ld.so.preload (在 chroot 中?)将目标可执行文件链接到这个库的魔法.

So it should be possible, and reasonably safe (so long as you're not over-writing any of the existing system libraries and just using LD_* /etc/ld.so.preload (in a chroot?) magic to link the target executables to this library.

但是,我认为这是一个坏主意.您遇到了包管理问题.Ubuntu 和 Red Hat 都有很好的包管理工具.使用它们!(请注意,询问有关包管理问题的正确位置是 ServerFault 或 SuperUser,绝对不是这样).

However, I think it's a bad idea. You have a package management issue. Both Ubuntu and Red Hat have fine package management tools. Use them! (Note the proper place to ask questions about package management would be ServerFault or SuperUser, definitely not SO).

这篇关于我可以在 Redhat Linux 机器上使用在 Ubuntu 上编译的共享库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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