ldconfig 动态更改本地library 版本问题

遇到一个问题,平台上的library版本被更新导致无法开机:

正常:

lrwxrwxrwx    1 19545752 19545752        14 Aug 11  2020 libxx.so -> libxx.so.2.0
-rw-rw-r--    1 19545752 19545752    326368 Aug 11  2020 libxx.so.2.0
-rwxrwxr-x    1 19545752 19545752    768172 Aug 11  2020 libxx.so.3.0

开机后变为:

lrwxrwxrwx    1 root    root                   14 Aug 11  2020 libxx.so -> libxx.so.3.0
-rw-rw-r--    1 19545752 19545752    326368 Aug 11  2020 libxx.so.2.0
-rwxrwxr-x    1 19545752 19545752    768172 Aug 11  2020 libxx.so.3.0

百思不得其解,查看代码也没有地方改变,最终发现是ldcofig会更新库的版本,源码中的注释:

   The algorithm is basically:
   for all libraries in the directory do
     get soname of library
     if soname is already in list
       if new library is newer, replace entry
       otherwise ignore this library
     otherwise add library to list

   For example, if the two libraries libxy.so.1.1 and libxy.so.1.2
   exist and both have the same soname, e.g. libxy.so, a symbolic link
   is created from libxy.so.1.2 (the newer one) to libxy.so.
   libxy.so.1.2 and libxy.so are added to the cache - but not
   libxy.so.1.1.  */

/* Information for one library.  */

 

 


NAME
       ldconfig - configure dynamic linker run-time bindings

SYNOPSIS
       /sbin/ldconfig [ -nNvXV ] [ -f conf ] [ -C cache ] [ -r root ] directory ...
       /sbin/ldconfig -l [ -v ] library ...
       /sbin/ldconfig -p

DESCRIPTION
       ldconfig  creates  the  necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in
       the trusted directories, /lib and /usr/lib (on some 64-bit architectures such as x86-64, lib and /usr/lib are the trusted directories for  32-bit  libraries,  while  /lib64  and
       /usr/lib64 are used for 64-bit libraries).

 

解决方式就是增加-X参数:

       -X     Don't update links.  Unless -N is also specified, the cache is still rebuilt.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值