I tried to build grpc c++ in two ways. One with -DBUILD_SHARED_LIBS=ON and one without it.
When it is off, I get in the lib/ directory, for example:
360M libgrpc.a
(Any many other libraries)
When it is ON, I get in the lib/ directory
lrwxrwxrwx 1 root root 13 Jul 8 11:32 grpc_so/lib/libgrpc.so -> libgrpc.so.41
lrwxrwxrwx 1 root root 17 Jul 8 11:32 grpc_so/lib/libgrpc.so.41 -> libgrpc.so.41.0.0
-rw-r--r-- 1 root rot 58M Jul 8 11:30 grpc_so/lib/libgrpc.so.41.0.0
(and many other .so files)
Why is such a difference in the library size? I read that static library contains its dependencies, but in fact even in the static build I do see other dependencies of grpc in the lib/ folder (example libabsl*.a files), so it is not like libgrpc.a
is self contained.
All the other libraries also have a larger size in the static build. What these .a files contains that the .so files do not?
I’m trying to get a small, runtime only grpc c++ build. Not sure if I should compile it as shared library or not.