Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use repoquery --whatprovides. Based on the so.* filenames provide guess for the .a library names. Note that repoquery --whatprovides, while searching for a library files, requires full path as an argument, e.g. repoquery --whatprovides /usr/lib64/librt.a returns glibc-static, but repoquery --whatprovides /lib64/librt.a does not work, so check for both /lib*.a (there may be some) and /usr/lib.*a candidates. Example for sh:

SO=`ldd /usr/bin/sh | cut -d ">" -f2 | cut -d"(" -f 1`

echo $SO
# result: /lib64/libtinfo.so.5 /lib64/libdl.so.2 /lib64/libc.so.6 /lib64/ld-linux-x86-64.so.2

A=$(for f in $SO; do a=`echo $f | sed 's/so.*/a/'`; echo $a; echo $a | sed 's#/lib#/usr/lib#'; done)

echo $A
# result: /lib64/libtinfo.a /usr/lib64/libtinfo.a /lib64/libdl.a /usr/lib64/libdl.a /lib64/libc.a /usr/lib64/libc.a /lib64/ld-linux-x86-64.a /usr/lib64/ld-linux-x86-64.a

for f in $A; do repoquery --whatprovides $f; done | LC_ALL=C sort | uniq
# or if you want to print information which package provides given .a
for f in `echo $A | LC_ALL=C sort | uniq`; do repoquery --whatprovides $f | xargs -I PKG sh -c "echo -n PKG:; repoquery --list PKG | grep $f"; done

# result:
# ncurses-static-0:5.9-12.20130511.fc20.x86_64:/usr/lib64/libtinfo.a
# glibc-static-0:2.18-11.fc20.x86_64:/usr/lib64/libdl.a
# glibc-static-0:2.18-11.fc20.x86_64:/usr/lib64/libc.a

In your case you need to link statically glibc (install yum install glibc-static). Search e.g. http://stackoverflow.com for static linking of glibc.

click to hide/show revision 2
dot in sed replacement

You can use repoquery --whatprovides. Based on the so.* filenames provide guess for the .a library names. Note that repoquery --whatprovides, while searching for a library files, requires full path as an argument, e.g. repoquery --whatprovides /usr/lib64/librt.a returns glibc-static, but repoquery --whatprovides /lib64/librt.a does not work, so check for both /lib*.a (there may be some) and /usr/lib.*a candidates. Example for sh:

SO=`ldd /usr/bin/sh | cut -d ">" -f2 | cut -d"(" -f 1`

echo $SO
# result: /lib64/libtinfo.so.5 /lib64/libdl.so.2 /lib64/libc.so.6 /lib64/ld-linux-x86-64.so.2

A=$(for f in $SO; do a=`echo $f | sed 's/so.*/a/'`; 's/.so.*/.a/'`; echo $a; echo $a | sed 's#/lib#/usr/lib#'; done)

echo $A
# result: /lib64/libtinfo.a /usr/lib64/libtinfo.a /lib64/libdl.a /usr/lib64/libdl.a /lib64/libc.a /usr/lib64/libc.a /lib64/ld-linux-x86-64.a /usr/lib64/ld-linux-x86-64.a

for f in $A; do repoquery --whatprovides $f; done | LC_ALL=C sort | uniq
# or if you want to print information which package provides given .a
for f in `echo $A | LC_ALL=C sort | uniq`; do repoquery --whatprovides $f | xargs -I PKG sh -c "echo -n PKG:; repoquery --list PKG | grep $f"; done

# result:
# ncurses-static-0:5.9-12.20130511.fc20.x86_64:/usr/lib64/libtinfo.a
# glibc-static-0:2.18-11.fc20.x86_64:/usr/lib64/libdl.a
# glibc-static-0:2.18-11.fc20.x86_64:/usr/lib64/libc.a

In your case you need to link statically glibc (install yum install glibc-static). Search e.g. http://stackoverflow.com for static linking of glibc.