Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to figure out the implications of a distribution where static binaries are preferred over shared ones. For that purpose, I put together a small Scala shell script that 1) traverses /bin, /sbin, /usr/bin, /usr/sbin directories, 2) locates non-symlink executables, and 3) sums the file size of the libraries listed by ldd. Is this a feasible approach to compute the extra space that would be needed?

Further, besides extra disk space consumption, what would be the runtime memory usage implications? That is, binaries compiled against the same shared library will let the kernel to instantiate the shared library just once at runtime. In case of static binaries, each binary will need to reserve extra memory for the very same library. With enough swap space, would still that be a problem? (After all, isn't that how most of the user-space Windows applications run?) Are there any other potential implications that I might be missing?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The key difference between static and shared libraries is that when static libraries are used every program has a copy of the parts of the library it uses. With a shared library the code is stored separately.

Windows like Linux uses a mixture of statically linked and shared libraries. In windows dll files are shared libraries in Linux the libraries usually have the extension .so

Programs written with static libraries are larger taking up more disk space. Also If two or more running programs are using the same library functions then this code will be in RAM multiple times. Depending on the complexity of the functions called this may mean more RAM is used and so may need to swap space more often. There is an overhead in calling a shared library so if the function is simple enough it may be more efficient in terms of RAM to have a static library.

If an error is discovered in a shared library then only the shared library needs to be updated. If the same error is discovered in a static library then all programs that use it need to be re-compiled and updated. On the other hand if a program is linked using static libraries there are no concerns about is the library available, and is it the correct version.

There are advantages and disadvantages to both approaches.

There is more information here

http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.