Created
March 3, 2016 11:13
-
-
Save michalfapso/833d4198244698e4266e to your computer and use it in GitHub Desktop.
Stripping symbols from a static library archive overcoming the error: "strip.exe: cannot create tempdir for archive copying (error: File exists)", when the library contains more than a few object files. The problem is in mktemp("stXXXXXX") which is able to create only 26 unique filenames on the MinGW system "mingw32_4.9.2-posix-sjlj-rt_v3-rev1"
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
#!/bin/bash | |
if [ $# -lt 2 ]; then | |
echo "Usage: $0 LIB_IN LIB_OUT STRIP_PARAMS" | |
echo "Example: $0 mylib_debug.a mylib_release.a --strip-debug" | |
fi | |
LIB_IN="$1"; shift; | |
LIB_OUT="$1"; shift; | |
LIB_IN="`realpath "$LIB_IN"`" | |
LIB_OUT="`realpath "$LIB_OUT"`" | |
echo "strip params: $@" | |
if [ -e "$LIB_OUT" ]; then | |
echo "ERROR: output library exists" | |
exit 1 | |
fi | |
TMP_DIR="`mktemp -d`" | |
cd $TMP_DIR | |
ar x "$LIB_IN" | |
mkdir stripped | |
for i in *.o; do | |
strip $@ -o stripped/$i $i | |
done | |
cd stripped | |
ar rs "$LIB_OUT" *.o | |
cd | |
rm -r $TMP_DIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment