how to ar x filename.a to different directory
Actually it is possible, maybe was changed recently, --output
option is what you need.
In your example:
ar x libclsr11.a --output tmp
The solution depends on the version of ar
. You can use ar --version
to display the version of ar
on your system.
For ar / GNU binutils before version 2.34:
Unfortunately, ar before version 2.34 does not provide a way to specify the directory where the files shall be extracted. (At least I was unable to find one.) It always uses the current directory. However, there is a simple workaround: Change to the target directory before extraction and use the relative path to the archive instead:
# cd ./tmp/
# ar x ../libclsr11.a
This way you should end up with clsrcact.o, clsrcclu.o and clsrccss.o inside the ./tmp/ directory.
For ar / GNU binutils version 2.34 or later:
Version 2.34 of binutils introduced the --output
for the ar
program. (See the changelog.) It can be used to specify the directory where the contents shall be extracted:
# ar x --output tmp libclsr11.a
That way the archive contents will land inside the tmp
directory without having to use the workaround for earlier ar
versions.