I'm trying to make a static binary of rm, so I tried compiling coreutils with
configure; make SHARED=0 CC='gcc -static'; make install
but I keep running into errors.
First make complains about c99 or gnu99, I solved that by adding -std=gnu99 to the CC value:
make SHARED=0 CC='gcc -static -std=gnu99'
After that it says:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbeginT.o: relocation R_X86_64_32 against `__TMC_END__' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.8/crtbeginT.o: error adding symbols: Bad value
I tried adding -fPIC like I added the -std option but to no avail.
Is it even possible to make static binaries of coreutils? (only interested in rm) If so, how? (I have 0 experience with building linux binaries)
PS: I downloaded the coreutils source from the ubuntu site, trusty.(coreutils-8.21)
CC
variable is not the right place for compiler flags. You should put those inCFLAGS
.rm
is the endgoal, simply installbusybox-static
orsash
.