Is a shared library dynamically or statically linked?

I have a trivial static library prepared from two object files

ld -shared -o libfoobar.so foo.o bar.o

When I check the type of the library file with the file utility, it reports that the library is dynamically linked:

file libfoobar.so
# libfoobar.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, with debug_info, not stripped

When I ask the same (?) question using ldd, it reports that the library is statically linked:

ldd libfoobar.so
# statically linked

How should I reconcile these two outputs?


uname -a
# Linux leo 4.15.0-124-generic #127-Ubuntu SMP Fri Nov 6 10:54:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
5 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like