Skip to content

Instantly share code, notes, and snippets.

@Leandros
Created January 28, 2018 23:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Leandros/b646f11dd6150f5d0055f52c65c6b224 to your computer and use it in GitHub Desktop.
Save Leandros/b646f11dd6150f5d0055f52c65c6b224 to your computer and use it in GitHub Desktop.
#!/bin/bash
ROOT=output
CC=x86_64-linux-musl-g++
CFLAGS="
-nostdinc
-isystem $ROOT/x86_64-linux-musl/include/c++/7.2.0
-isystem $ROOT/x86_64-linux-musl/include/c++/7.2.0/x86_64-linux-musl
-isystem $ROOT/x86_64-linux-musl/include/c++/7.2.0/backward
-isystem $ROOT/x86_64-linux-musl/include/
-isystem $ROOT/lib/gcc/x86_64-linux-musl/7.2.0/include"
LDFLAGS="
-nostdlib
-nodefaultlibs
-nostartfiles
-static
-L$ROOT/x86_64-linux-musl/lib
-L$ROOT/lib"
LIBS="-Wl,--start-group -lstdc++ -lc -lgcc -Wl,--end-group"
STARTFILES="
$ROOT/x86_64-linux-musl/lib/crt1.o
$ROOT/x86_64-linux-musl/lib/crti.o
$ROOT/lib/gcc/x86_64-linux-musl/7.2.0/crtbegin.o"
ENDFILES="
$ROOT/lib/gcc/x86_64-linux-musl/7.2.0/crtend.o
$ROOT/x86_64-linux-musl/lib/crtn.o"
$CC $CFLAGS -o foo.o -c foo.cpp
$CC $LDFLAGS -o foo $STARTFILES foo.o $ENDFILES $LIBS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment