针对符号链接而不是 soname 进行链接
我有一个 Linux 应用程序,它在链接器行上链接到: libpython2.6.so
这最终解析为 libpython.2.6.so.1.0
/usr/lib/libpython2.6.so -> libpython2.6.so.1
/usr/lib/libpython2.6.so.1 -> libpython2.6.so.1.0
,其中嵌入了 SONAME ,因此我只能将其链接到完整版本的名称。
g++ foo.cc /usr/lib/libpython2.6.so
ldd ./a.out | grep python
libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00007fd36f7ab000)
这意味着如果存在 libpython2.6.so.1.1,我的应用程序最终将崩溃。是否有办法强制我的应用程序使用通用名称 libpython2.6,而不是 libpython2.6.so.1.0?
我使用了这么小的一组 python API,我认为我应该可以安全地链接到该库的更通用的版本名称。
I have an linux application, which on the linker line links against:
libpython2.6.so
This ultimately resolves to libpython.2.6.so.1.0
/usr/lib/libpython2.6.so -> libpython2.6.so.1
/usr/lib/libpython2.6.so.1 -> libpython2.6.so.1.0
Which has SONAME embedded in it so that I am stuck with it linking against the fully versioned name.
g++ foo.cc /usr/lib/libpython2.6.so
ldd ./a.out | grep python
libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00007fd36f7ab000)
This means that my application will ultimately break if there is ever a libpython2.6.so.1.1. Is there anyway to force my application to use the generic name libpython2.6, instead of libpython2.6.so.1.0?
I use such a small set of the python API, that I think I should be safe linking against a more generic version name of the library.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看``3.1.1。 http://tldp.org/HOWTO/Program 中的共享库名称 '' -Library-HOWTO/shared-libraries.html ,这可以帮助您了解共享库的命名方法。
Have a look at ``3.1.1. Shared Library Names '' in http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html , this may help you understand the naming method of share library.
不用担心libpython2.6的SO版本增加。永远不会增加; 2.6 不会有任何进一步的错误修复版本,即使有,SO 版本也不会增加。
您应该担心 libpython2.6 在系统的未来版本中消失(被 libpython2.7 取代)。目前还没有什么好的解决方案;使用 PEP 384,您将能够链接到 libpython3.so。
Don't worry about the SO version of libpython2.6 increasing. It will never increase; there won't be any further bugfix releases to 2.6, and even if there were, the SO version would not be increased.
You should rather worry about libpython2.6 going away in future releases of the system (to be replaced by libpython2.7). There isn't any good solution to that, yet; with PEP 384, you will be able to link with libpython3.so.