Is a Shared Library Dynamically or Statically Linked?

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
David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.