Issue
Is it possible to compile a program using gcc without depending on glibc?
void main(){}
./libtest: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./libtest)
EDIT: It seems I had to compile with -nostdlib -nostartfiles -nodefaultlibs
Solution
Is it possible to compile a program using gcc without depending on glibc?
Yes, there are alternative libc
versions, such as Musl, uClibc, dietLibc, etc. See their documentation on how to use them.
Your problem does not appear to be a GLIBC dependency, but rather a mismatch between your build and your target hosts. In particular, your target has older GLIBC than your build host.
The easiest to solution for that problem is to build on an old-enough system -- your binary will run on anything that is as-old or newer. You could do that inside a VM or in a docker container, so you don't have to downgrade your main system.
You could also link your program statically (add -static
flag), but beware -- for many non-trivial programs this will make your binary less portable.
Answered By - Employed Russian Answer Checked By - Clifford M. (WPSolving Volunteer)