在Linux上使用ldconfig [英] Using ldconfig on Linux

查看:107
本文介绍了在Linux上使用ldconfig的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我已将库foo.so.1.1.1添加到/etc/ld.so.conf中包含的路径中 在系统上运行ldconfig时,我获得了foo.so.1.1和foo.so.1到foo.so.1.1.1的链接

Let's say I 've added a library foo.so.1.1.1 to a path that is included in /etc/ld.so.conf When I run ldconfig on the system I get the links foo.so.1.1 and foo.so.1 to foo.so.1.1.1

如何更改行为以也将foo.so链接获取到foo.so.1.1.1?

How can I change the behavior to also get the foo.so link to foo.so.1.1.1?

推荐答案

ldconfig在找到的所有共享对象中查找soname.然后,它将使用该soname作为链接的名称来创建链接.将soname用作库的名称和主要版本是常规的(但远没有做到),因此您的库foo.so.1.1的soname为foo.so.1,而ldconfig会创建一个链接.

ldconfig looks inside all shared objects that it finds, to look for the soname. It then creates a link using that soname as the name of the link. It's conventional (but far from universally done) for the soname to be the name and major version of the library, so your library foo.so.1.1 will have a soname of foo.so.1 and ldconfig will make a link called that.

运行时系统的任何部分都不会查找或不知道有关名称foo.so的任何信息.当您将程序链接到库时使用.除非您还拥有该库的所有其他开发文件(标头等),否则没有链接是没有意义的,因此ldconfig自动创建它是没有意义的.而且,由于要使用的链接名称仅是另一种约定,在这种情况下根本没有存储在文件中,因此ldconfig无法知道要创建的名称.

No part of the run-time system looks for or knows anything about the name foo.so. That's used when you link your programs to the library. There's no point in having that link unless you also have all the other development files (headers etc) for the library, so there's no point in ldconfig automatically creating it. And since the name of the link to use is only another convention, and in this case isn't stored inside the file at all, there's no way for ldconfig to know what name to create.

通常,这是在Makefile的安装目标中手动创建的;当为Linux发行版打包了一个库时,该链接通常与头文件一起位于-dev包中.

Normally this would be created manually, in the install target of the Makefile; when a library is packaged for a linux distribution the link normally lives in the -dev package along with the header files.

这篇关于在Linux上使用ldconfig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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