从 ldd 输出复制所有共享对象

Copy all shared objects from ldd output

如何从我的可执行文件的 ldd 输出中复制所有共享对象?

我正在寻找类似的东西,但这是给 find 的,我需要 ldd:

find -name "*python3.7*" -exec cp "{}" /home/user/python/arm-linux-gnueabihf/ \;

编辑:

ldd 输出示例:

adrian@adrian:~/Dokumenty/PracaMagisterska/eclipse/0_FULL_GAME$ ldd 0_FULL_GAME
    linux-vdso.so.1 (0x00007ffcc15fc000)
    libsfml-window.so.2.5 => /usr/lib/x86_64-linux-gnu/libsfml-window.so.2.5 (0x00007ff1f8d57000)
    libpython3.8.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.8.so.1.0 (0x00007ff1f8809000)
    libsfml-system.so.2.5 => /usr/lib/x86_64-linux-gnu/libsfml-system.so.2.5 (0x00007ff1f87fb000)
    libsfml-graphics.so.2.5 => /usr/lib/x86_64-linux-gnu/libsfml-graphics.so.2.5 (0x00007ff1f87a3000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff1f85c2000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff1f8473000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff1f8456000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff1f8264000)
    libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007ff1f8127000)
    libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007ff1f811a000)
    libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007ff1f8092000)
    libudev.so.1 => /lib/x86_64-linux-gnu/libudev.so.1 (0x00007ff1f8066000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007ff1f8036000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff1f801a000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff1f7ff7000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff1f7ff1000)
    libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007ff1f7fec000)
    libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007ff1f7f2d000)
    /lib64/ld-linux-x86-64.so.2 (0x00007ff1f8e00000)
    libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007ff1f7f01000)
    libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007ff1f7eec000)
    libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007ff1f7ce2000)
    libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007ff1f7c2a000)
    libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0 (0x00007ff1f7bf6000)
    libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007ff1f7bbc000)
    libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007ff1f7bb6000)
    libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007ff1f7bae000)
    libbsd.so.0 => /usr/lib/x86_64-linux-gnu/libbsd.so.0 (0x00007ff1f7b94000)

上面的示例 ldd 输出已保存到“infile”。说明:运行 awk 到 select 行,有 4 个字段和 echo 一个将 lib 从第三个字段复制到目标目录的命令:

awk 'NF == 4 { system("echo cp "  " destdir") }' infile

不是从 infile 中读取,而是可以将 ldd 的输出通过管道传输到 awk,例如:

ldd 0_FULL_GAME | awk 'NF == 4 { system("echo cp "  " destdir") }'

将 destdir 替换为您选择的目录。一旦显示的命令看起来正常,删除 echo 以实际复制,例如:

ldd 0_FULL_GAME | awk 'NF == 4 { system("cp "  " chosen-dir") }'