Harry
Harry

Reputation: 3052

create a tar of the files listed by ldd command including symbolic links and the binary

How to create a tar.gz file containing all the dependencies of a given binary including the symbolic links and also the binary a.out. This is what I tried

ldd some-proj/build/a.out | tar -hcvf some-proj.tar.gz -T -

ldd output

    linux-vdso.so.1 (0x00007ffd54a88000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007faa62b15000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007faa62ae7000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007faa628d3000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007faa62651000)
    /lib64/ld-linux-x86-64.so.2 (0x00007faa633b7000)

Error

tar: \tlinux-vdso.so.1 (0x00007ffefeae7000): Cannot stat: No such file or directory
tar: \tlibstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f09e249b000): Cannot stat: No such file or directory
tar: \tlibgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f09e246d000): Cannot stat: No such file or directory
tar: \tlibc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f09e2259000): Cannot stat: No such file or directory
tar: \tlibm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f09e1fd7000): Cannot stat: No such file or directory
tar: \t/lib64/ld-linux-x86-64.so.2 (0x00007f09e2d3d000): Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

Upvotes: 0

Views: 28

Answers (1)

Toby Speight
Toby Speight

Reputation: 30931

You need a processing step in your pipeline to extract just the filenames.

E.g.

    …  | 
   sed -e 's/^\t//' \
       -e 's/.* => //' \
       -e 's/ .*//' \
       -e  '/\//!d' |
   …

Upvotes: 0

Related Questions