Dependence hell: dynamic loading of the linux.so plugin

I created a shared library built with a standalone build tree using linuxbrew, which does not load in the parent application due to a dependency conflict. I use a separate application that dynamically loads the library after starting with Qt5 QLibrary.

My library libv_repExtPluginSkeleton.so. Both he and the parent application depend on glibc and libstdC ++. All major application dependencies are in /usr/lib, and all my dependencies in the library are in ~/.linuxbrew/lib.

When the parent application goes to download the .socrash, I debugged the crash with LD_DEBUG=all "$dirname/$appname"and found the following error report in the report:

  2610: file=/home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so [0];  dynamically loaded by libQt5Core.so.5 [0]
  2610: file=/home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so [0];  generating link map
  2610:   dynamic: 0x00007fd063cff570  base: 0x00007fd063ae7000   size: 0x000000000021a6a8
  2610:     entry: 0x00007fd063af1150  phdr: 0x00007fd063ae7040  phnum:                  5
  2610: 
  2610: checking for version `GCC_3.0' in file /lib/x86_64-linux-gnu/libgcc_s.so.1 [0] required by file /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so [0]
  2610: checking for version `GLIBC_2.14' in file /lib/x86_64-linux-gnu/libc.so.6 [0] required by file /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so [0]
  2610: checking for version `GLIBC_2.2.5' in file /lib/x86_64-linux-gnu/libc.so.6 [0] required by file /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so [0]
  2610: checking for version `CXXABI_1.3' in file /usr/lib/x86_64-linux-gnu/libstdc++.so.6 [0] required by file /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so [0]
  2610: checking for version `GLIBCXX_3.4.9' in file /usr/lib/x86_64-linux-gnu/libstdc++.so.6 [0] required by file /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so [0]
  2610: checking for version `GLIBCXX_3.4.21' in file /usr/lib/x86_64-linux-gnu/libstdc++.so.6 [0] required by file /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so [0]
  2610: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: error: version lookup error: version `GLIBCXX_3.4.21' not found (required by /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so) (fatal)
  2610: 
  2610: file=/home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so [0];  destroying link map

, , glibc /usr/lib, , ~/.linuxbrew/lib.

QLibrary :

plug=new CPlugin(filename,pluginName);
int loadRes=plug->load();

Inside Story on Shared Libraries Dynamic Loading, " ", . , .

, ldd, :

+ ldd /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/libv_repExtPluginSkeleton.so
    linux-vdso.so.1 (0x00007fffc17af000)
    libstdc++.so.6 => /home/hbr/.linuxbrew/lib/libstdc++.so.6 (0x00007ff5b9a32000)
    libm.so.6 => /home/hbr/.linuxbrew/lib/libm.so.6 (0x00007ff5b9742000)
    libgcc_s.so.1 => /home/hbr/.linuxbrew/lib/libgcc_s.so.1 (0x00007ff5b9531000)
    libc.so.6 => /home/hbr/.linuxbrew/lib/libc.so.6 (0x00007ff5b91b9000)
    /home/hbr/.linuxbrew/Cellar/glibc/2.19/lib64/ld-linux-x86-64.so.2 (0x00007ff5b9f81000)
+ ldd /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/vrep
    linux-vdso.so.1 =>  (0x00007ffc333f9000)
    liblua5.1.so (0x00007fc10e763000)
    libQt5Core.so.5 (0x00007fc10df28000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc10dd0a000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc10da06000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc10d7f0000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc10d42b000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc10d125000)
    libicui18n.so.54 (0x00007fc10ccb7000)
    libicuuc.so.54 (0x00007fc10c909000)
    libicudata.so.54 (0x00007fc10aedf000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc10acdb000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fc10aad9000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fc10a8d1000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fc10a5c9000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fc10e66d000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fc10a38b000)
+ LD_DEBUG=all /home/hbr/V-REP_PRO_EDU_V3_2_2_64_Linux/vrep

script LD_LIBRARY_PATH ~/.linuxbrew/lib, - .

, RPATH :

objdump -x libv_repExtPluginSkeleton.so |grep RPATH
RPATH                /home/hbr/.linuxbrew/lib

, ?

, , ?

+4
5

, . vrep.

vrep.sh, LD_LIBRARY_PATH, .

unset LD_LIBRARY_PATH

@fireant , , , .

postoverflow post rpath , rpath:

objdump -x binary-or-library |grep RPATH

# Maybe an even better way to do it is the following:
readelf -d binary-or-library |head -20

# This second command above also lists the direct dependencies on other libraries followed by rpath.

# On ubuntu 15.04 someone had to use:
objdump -x binary-or-library |grep RUNPATH

vrep 3.2.2 rpath, , , , , vrep :

$ objdump -x vrep |grep RPATH
  RPATH                /home/marc/Qt5.2.0/5.2.0/gcc_64:/home/marc/Qt5.2.0/5.2.0/

, $VREPDIR/lib, , ~/.linuxbrew/lib, rpath vrep :

VREPDIR=/path/to/vrep/executable
cd $VREPDIR
ln -s ~/.linuxbrew/lib $VREPDIR/lib
patchelf --set-rpath '$ORIGIN/lib' vrep

, ld/rpath/patchelf $ORIGIN , vrep. , RUNPATH (RPATH vs runpath - ?):

$ objdump -x vrep |grep RUNPATH
  RUNPATH              $ORIGIN/lib

, , , , Qt linuxbrew :

libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007fece8993000)

API, V-REP Qt, vrep, linuxbrew. , vrep 2 3.so ! , , , vrep, .

, vrep , .linuxbrew. , , / vrep.

, , , . , , , , .

0

, ?

, libc libstdc++. ( , , , ..) - . , STL libstdc++ . std::string std::string . / . ( , libstdc++, .) , ( libstdc++ ), STL / - C.

, , Linux/UNIX . soname, . , . , , , . , , .

, :

  • . . , libc libstdc++.

  • /. , , RPC . , . , (rpath LD_PRELOAD).

, , libc libstdc++, , .

+3

, rpath . . , .

+1

, Linux. . , ++.

, 3 , : libc, libgcc_s libstdc++ (libm , ).

(libc) , . , . GNU C . . libc.so.6 ( 2.11 , , , , ) . libv_repExtPluginSkeleton.so. , , libv_repExtPluginSkeleton.so ( ) . .

, , (rpath ed) libgcc_s libstdc++, . , , . , .

-, , , libc. , . , libstdc++ ELF ( ). . ( libv_repExtPluginSkeleton.so , std::string, ).

libgcc_s libstdc++. , . -static-libgcc -static-libstdc++. , , . libv_repExtPluginSkeleton.so ++ ++ . , libstdc++ .

, , :

  • libc, , . .
  • libgcc_s libstdc++ .
  • C, () .

, , , . ++. libc . .

, .

0

- , . Vim , ~/.linuxbrew/lib. . - , , ~/.linuxbrew/lib. , / . , - /.

0

Source: https://habr.com/ru/post/1613726/


All Articles