How can I copy all shared objects from ldd
output of my executable?
I'm looking for something like this, but this is for find
and I need for ldd
:
find -name "*python3.7*" -exec cp "{}" /home/user/python/arm-linux-gnueabihf/ \;
EDIT:
Example of ldd
output:
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)
The example ldd
output above was saved to "infile". Description: run awk
to select lines with 4 fields and echo
a command that would copy the lib from the third field to a destination directory:
awk 'NF == 4 { system("echo cp " $3 " destdir") }' infile
Instead of reading from infile, could pipe the output from ldd
into awk
, eg:
ldd 0_FULL_GAME | awk 'NF == 4 { system("echo cp " $3 " destdir") }'
Replace destdir with your directory of choice. Once the displayed commands look OK, remove the echo
to actually copy, eg:
ldd 0_FULL_GAME | awk 'NF == 4 { system("cp " $3 " chosen-dir") }'