如何指定链接时使用的库版本?
以下问题应用程序如何解析运行时使用不同版本的共享库?,我想知道如何在链接命令行上指定使用哪个版本的库?
假设我有
libmy.so.1.0
libmy.so.1 -> libmy.so.1.0
libmy.so.2.0
libmy.so.2 -> libmy.so.2.0
libmy.so -> libmy.so.2
指定与可执行文件链接的库的常用方法,但不显示要使用的版本。此外,人们很可能想要链接到最新版本。因此,在大多数情况下,通常的线路工作得很好。
gcc app.o -lmy -o app
链接应使用库版本 1 的 app
的命令行是什么?
Following question How do applications resolve to different versions of shared libraries at run time?, I wondered how to specify on the link command line which version of the library to use?
Let's say I have
libmy.so.1.0
libmy.so.1 -> libmy.so.1.0
libmy.so.2.0
libmy.so.2 -> libmy.so.2.0
libmy.so -> libmy.so.2
The usual way to specify the library to link with the executable does not show the version to use. Furthermore, it is very likely that one wants to link with the most recent version. Thus the usual line works fine in most cases.
gcc app.o -lmy -o app
What is the command line to link app
that should use version 1 of the library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
链接器也能够接受
来自
man ld
的文件名:我注意到旧版本不支持它,因此请检查系统上的
man ld
-l
或--library
选项。您还可以链接到提及其全名的文件
The linker is able to accept filenames too
From
man ld
:I noticed that older versions do not support it, so check
man ld
-l
or--library
option on your system.You could also link to the file mentioning its full name