I am using gcc 5.4.0 on Ubuntu 16.04 64 bit. When I compile a program:
gcc -o prog prog.c
GCC automatically links to the C standard library, so I don't have to specifically do that.
Thanks in advance.
However libc has not been linked in statically, only dynamically, so it is another failed attempt.
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.
One can also use clang with Microsoft Visual Studio C and C++ libraries.
How can I see which C library does gcc links against to, libc.a or libc.so, or something else?
You can use ldd
command to see all linked shared libraries. If libc.so
is found, it's dynamic linking.
In what circumstance does it links to libc.so?
gcc uses dynamic linking and links to libc.so
by default. If you want static linking, pass -static
flag.
Does libc.so need to be specified at run time like other shared libraries?
Normally no, since it's configured by compiler automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With