Linux中 SONAME 的作用

一、从 -lexample 到 SONAME

✅ 假设你有以下文件结构:

/libexample.so        → libexample.so.1
/libexample.so.1      → libexample.so.1.0.0
/libexample.so.1.0.0  # SONAME: libexample.so.1

/libexample.so.2      → libexample.so.2.0.0
/libexample.so.2.0.0  # SONAME: libexample.so.2

这些是典型的共享库软链结构。

soname相关命令参考

命令 用途
手动设置 SONAME gcc -shared -Wl,-soname,libexample.so.1 -o libexample.so.1.0.0 example.c
查看库的 SONAME readelf -d libexamp

你可能感兴趣的:(C语言高手修炼营,C++高手修炼营,c++,linux,soname,动态库)