Skip to content

Instantly share code, notes, and snippets.

@ekimekim
Last active December 4, 2015 06:04
Show Gist options
  • Save ekimekim/33fbe944508da6cfce86 to your computer and use it in GitHub Desktop.
Save ekimekim/33fbe944508da6cfce86 to your computer and use it in GitHub Desktop.
lddcopy - A script to copy all required libraries to a output directory
#!/bin/bash
USAGE="$0 EXECUTABLE PATH
For all shared libraries used by EXECUTABLE, copy that .so file to PATH"
if [ "$#" -ne 2 ]; then
echo "$USAGE" >&2
exit 1
fi
executable="$1"
path="$2"
if ! [ -d "$path" ]; then
echo "PATH must be a directory"
exit 1
fi
ldd "$executable" |
awk '$2 == "=>" && $3 " " $4 != "not found" {print $1, $3}' |
while read name libpath; do
echo "Copying $name at $libpath"
cp "$libpath" "$path"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment