你如何链接到 GCC 中共享库的特定版本 [英] How do you link to a specific version of a shared library in GCC

查看:31
本文介绍了你如何链接到 GCC 中共享库的特定版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编译一些在 Debian Linux 系统上使用 libcurl 的代码.我的开发机器运行的是 Debian 5,但我希望二进制文件也能在较旧的 Debian 4 系统上使用.

I'm compiling some code which uses libcurl on a Debian Linux system. My dev machine is running Debian 5 but I want the binary to be usable on older Debian 4 systems too.

我发现如果我指定 -lcurl 它将链接到 libcurl.so.4 但 Debian 4 系统只有 libcurl.so.3

I find that if I specify -lcurl it will link to libcurl.so.4 but Debian 4 systems only have libcurl.so.3

有什么方法可以告诉 GCC 链接到 libcurl.so.3(在 Debian 4 和 5 中都存在)或只链接到 libcurl.so 以便它使用任何可用的版本?

Is there some way I can tell GCC to link to either libcurl.so.3 (which exists in both Debian 4 and 5) or just libcurl.so so it will use whatever version is available ?

推荐答案

你可以在链接器命令行上传递实际的 .so 文件而不是 -l,它应该做你想做的事.

You can pass the actual .so file instead of -l on the linker command line, and it ought to do what you want.

这篇关于你如何链接到 GCC 中共享库的特定版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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