Skip to content

Instantly share code, notes, and snippets.

@SamRH
Created December 30, 2011 07:15
Show Gist options
  • Save SamRH/1538432 to your computer and use it in GitHub Desktop.
Save SamRH/1538432 to your computer and use it in GitHub Desktop.
A script to find and copy required DLLs of an executable to the current directory
#!/bin/bash
DLLBINDIR='/usr/i686-pc-mingw32/sys-root/mingw/bin/'
function usage
{
echo "Usage: `basename $0` file.exe"
echo \
"copies required dynamically linked libraries to \
the current directory"
}
if [ $# -ne 1 ]
then
usage
exit 1
fi
if [ ! -f "$1" ]
then
usage
fi
EXE=$1
DLLS=$(i686-pc-mingw32-objdump -p $EXE | grep 'DLL Name: ' | sed 's/\tDLL Name: //')
for i in $DLLS
do
if [ -f ${DLLBINDIR}${i} ]
then
cp -f "${DLLBINDIR}${i}" .
echo "Copied $i to current directory"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment