链接linux中的特定共享库版本

时间:2022-09-18 12:26:55

My build process consists of Qt's qmake Makefile generator and the typical make utility bundled with linux.
My application consists of a few shared libraries and the main application is linked against them.
How can I apply the typical linux versioning scheme on my libraries? (Use version 2 -> link against foo.so.2 that points to foo.so.2.y.z with an ldconfig generated link).

我的构建过程包括Qt的qmake Makefile生成器和与linux捆绑在一起的典型make实用程序。我的应用程序由几个共享库组成,主应用程序与它们相关联。如何在我的库上应用典型的linux版本控制方案? (使用版本2 - >指向foo.so.2的链接,指向带有ldconfig生成链接的foo.so.2.y.z)。

The answer doesn't have to be specific for my build process.

答案不必具体针对我的构建过程。

1 个解决方案

#1


8  

Your library should be named libfoo.so.2.y.z, with symlinks of libfoo.so.2 and libfoo.so both pointing to that. The library should be created using -soname libfoo.so.2 in the linker command line (or -Wl,-soname,libfoo.so.2 on the gcc command line).

您的库应该命名为libfoo.so.2.y.z,其中符号链接libfoo.so.2和libfoo.so都指向它。应使用链接器命令行中的-soname libfoo.so.2(或gcc命令行上的-Wl,-soname,libfoo.so.2)创建库。

Hope that helps!

希望有所帮助!

#1


8  

Your library should be named libfoo.so.2.y.z, with symlinks of libfoo.so.2 and libfoo.so both pointing to that. The library should be created using -soname libfoo.so.2 in the linker command line (or -Wl,-soname,libfoo.so.2 on the gcc command line).

您的库应该命名为libfoo.so.2.y.z,其中符号链接libfoo.so.2和libfoo.so都指向它。应使用链接器命令行中的-soname libfoo.so.2(或gcc命令行上的-Wl,-soname,libfoo.so.2)创建库。

Hope that helps!

希望有所帮助!