Created
February 7, 2014 13:41
-
-
Save ldx/8862808 to your computer and use it in GitHub Desktop.
Find library via checking gcc/ld search directories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find_lib() { | |
_lib="$1" | |
_sysroot="$(gcc -print-sysroot)" | |
_gcc_searchdirs=$(gcc -print-search-dirs|grep '^libraries'|sed -e 's/^libraries: //g' -e 's/:/ /g' -e "s/=/\$sysroot/g") | |
_ld_searchdirs=$(ld --verbose|grep SEARCH_DIR|sed -e 's/SEARCH_DIR("//g' -e 's/");//g' -e "s/=/\$sysroot/g") | |
for d in $_gcc_searchdirs $_ld_searchdirs; do | |
if [ -f "$d/$_lib" ]; then | |
echo -n "$d/$_lib" | |
return | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment