Reputation: 449
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.
Upvotes: 6
Views: 3881
Reputation: 16444
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.
Upvotes: 8