如何建立一个既需要的libstdc ++。so.5的和libstdc ++。so.6的应用程序? [英] How to build an application that requires both libstdc++.so.5 and libstdc++.so.6?

查看:221
本文介绍了如何建立一个既需要的libstdc ++。so.5的和libstdc ++。so.6的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要preface这与重要通知我不是一个C / C ++程序员的,知道的很少的有关图书馆的联动如何工作的温度。

I want to preface this with the important notice that I am not a C/C++ programmer, and know very little about how linkage of libraries works in C.

我们的code使用的libstdc ++。so.6(GCC 3.4,我认为)。我们有第三方precompiled(闭源)使用的libstdc ++库。so.5的(GCC 2.something或3.2,我认为)。这是在Linux上。我们有一个u和第三方的lib中的.so版本。

Our code uses libstdc++.so.6 (gcc 3.4, i think). We have third-party precompiled (closed source) libraries that use libstdc++.so.5 (gcc 2.something or 3.2, i think). This is on linux. We have both a .a and .so version of the third party lib.

是否有可能建立我们的应用程序的第三方库?怎么样?是否有可能建立/,而无需的libstdc ++运行我们的应用程序。安装so.5的我们的我们的机器,怎么样?

Is it possible to build our app with the 3rd party libs? How? Is it possible to build/run our app without having libstdc++.so.5 installed our our machines, how?

如果我忘了一些关键的信息,请让我知道 - 我几乎不知道什么有关这个东西。我认识到,一个完整的答案恐怕是不可能的;我真的在寻找方向和指导。静态链接这一点,即动态,重建,prebuild某某的话,切换到x版本,或符号链接quizdoodle等。

If I've forgotten some critical information, please let me know - I hardly know whats relevant with this stuff. I realize that a complete answer probably won't be possible; I'm really looking for direction and guidance. Static link this, dynamic that, rebuild that, prebuild so-and-so, switch to version x, or symlink the quizdoodle, etc.

更新:

我们尝试使用的dlopen RTLD_LOCAL 的第三方库,从我们的应用程序的其他部分隔离开来。这似乎已的大多的工作,但是,我们剩下的,原因不明的大内存泄漏。我们怀疑,当我们调用的dlopen ,第三方库中的符号像拉的malloc 从已加载的.so .6和事情变得糊涂起来。

We tried using dlopen with RTLD_LOCAL to isolate the 3rd party library from the rest of our app. This seems to have mostly worked, however, we are left with large memory leaks for unknown reasons. We suspect that, when we call dlopen, the third party library pulls in symbols like malloc from the already loaded .so.6, and things get muddled up.

有关的笑声中,我们试图把第三方库到 LD_ preLOAD ,然后跑我们的应用程序,而内存泄漏似乎完全消失。

For giggles, we tried putting the third-party library into LD_PRELOAD, then ran our app, and the memory leaks seems to completely disappear.

推荐答案

您可以尝试建立一个围绕你的第三方库的封装库:使用该库的静态版本+与静态的标准库连接(-static- libgcc的 - 确保你通过-L拿起一个正确的版本)。做最重要的事情是正确地关闭这个包装库,即只从原来的第三方库的符号应该出口,其他一切都应该被隐藏。你包装库这样会暴露你的应用程序所需的所有符号和内部封装标准的东西。注意它不能保证特别是工作,如果一些内存操作的code和第三方code之间共享(如你在code和第三方解除分配分配内存)......在这种情况下唯一的选择可以保持这个第三方的lib在不同的进程空间中。

You may try to build a wrapper library around your 3rd party library: use the static version of that library + link it with the static standard library (-static-libgcc - make sure you pick up a proper version via -L). The important thing to do is to close this wrapper library properly, i.e only symbols from the original 3rd party library should be exported, everything else should be hidden. This way you wrapper library will expose all needed symbols for your application and encapsulate standard stuff inside. Note it is not guaranteed to work especially if some memory operations are shared between your code and 3rd party code (e.g. you allocate memory in your code and deallocate in 3rd party)... in such case the only option can be to keep this 3rd party lib in a different process space.

我不认为上面提到的动态选项会工作,因为你会得到完全一样的问题 - 后来才

I don't think the dynamic option mentioned above would work because you will get exactly same problem - just later.

在一般最好不要在同一个进程空间中混合了不同的运行时间二进制文件。它几乎总是一个灾难。

In general it is better not to mix binaries with different run-times in the same process space. It is almost always a recipe for disaster.

这篇关于如何建立一个既需要的libstdc ++。so.5的和libstdc ++。so.6的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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