C ++两个库依赖于相同的库,但版本不同? [英] C++ two libraries depend on same lib but different versions?

查看:329
本文介绍了C ++两个库依赖于相同的库,但版本不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用GCC编译器在C ++中具有库A,B和C。库A和库B都依赖于C,但依赖于它的不同版本。然后可以在另一个程序中同时使用A和B吗?还是A和B要求的C不同版本会发生冲突?以及我该如何解决?

If i have libs A, B and C in C++ using GCC compiler. Lib A and B both depend on C but on different versions of it. Can i then use A and B together in another program? or will the different versions required of C by A and B conflict? And how do i resolve this and can i?

推荐答案

我假设您正在动态链接。如果A和B都完全封装了它们各自的C版本,则可能可以这样做。您可能必须确保不同版本的C的名称不同(即libMyC.1.so和libMyC.2.so),以避免在运行时加载它们时造成混淆。

I'm assuming that you're linking dynamically. If both A and B completely encapsulate their respective versions of C then it might be possible to do this. You might have to make sure that the different versions of C are named differently (i.e. libMyC.1.so and libMyC.2.so) to avoid confusion when they are loaded at runtime.

您还可以静态研究A和B的构建,以避免运行时负载混乱的可能性。

You could also investigate statically building A and B to avoid the possiblility of runtime load confusion.

最简单的找出方法就是尝试一下。

Simplest way to find out is simply to try it. It shouldn't take to long to determine if it'll work or not.

最后,当然,到目前为止,最简单的解决方案是,从维护角度来看,最好的解决方案是将A或B提升到另一个水平,以便它们都使用相同的C版本。这在许多方面都更好,我强烈敦促尝试解决实际问题。

Lastly, of course, by far the easiest solution, and best from a maintenance perspective is to bring A, or B, up to the level of the other so that they both use the same version of C. This is better in so many ways and I strongly urge you to do that rather than to try working around a real problem.

这篇关于C ++两个库依赖于相同的库,但版本不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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