linux - 联动后设置SONAME

标签 linux shared-libraries gnu

考虑以下共享库的创建。有可能做到吗

g++ -shared -o __targets/libfoo.so libfoo.cpp
some command that sets SONAME of __targets/libfoo.so to libfoo.so.X

代替

g++ -shared -o __targets/libfoo.so -Wl,-soname,libfoo.so.X libfoo.cpp

问题是发布链接命令的模块不知道版本号。

最佳答案

就个人而言,我一开始并不认为这是个好主意,但如果您真的需要它,可以使用一个名为 patchelf 的程序。 .它甚至有可能已经打包为您的发行版的一部分。因此,您应该能够在第二步通过调用以下命令设置 soname:

patchelf --set-soname libfoo.so.X __targets/libfoo.so

关于linux - 联动后设置SONAME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45392319/

相关文章:

makefile - GNU Make 中的条件依赖

php - ftp_get 损坏音频文件

linux - Makefile 和 Shell 脚本 (Bash)

c - *(void **) (&funcp) 在这行涉及 dlsym() 的代码中做了什么?

c++ - 关于 Linux 上的共享库的良好做法是什么?

c++ - 动态链接 - Linux 与 Linux Windows

c++ - 在 strlen 函数中的 solaris vsnprintf 核心转储中有什么方法可以解决这个问题?

使用 mkl 和 GNU C/C++ 编译时 cc1plus : error: argument to '-O' should be a non-negative integer, 'g' 、 's' 或 'fast' 错误

python - shell脚本监视日志中的 "word",然后终止并重新启动进程

linux - 如何在 QML 中编写条件导入语句?