ShopSite Knowledgebase

What is the Difference Between Dynamic and Static Files

Product: ShopSite SC + TX
Version: Any
Platform: Any UNIX Platform (including Cobalt RAQ)

Often there is mention of static versus dynamic versions of a ShopSite CGI executable file. What is the difference?
Solution ID: S04240

Every UNIX program/executable can be thought of as static or dynamically compiled, or static and dynamically built. When a UNIX program is static, all the necessary libraries required for that program to run are built into the executable. When a UNIX program is dynamic, all the necessary libraries required for that program to run are located on the UNIX file system. In the case of dynamic programs, the UNIX libraries are considered "shared libraries" or "objects", and are often located in /usr/lib.
Static UNIX programs have the advantage that there are no dependencies on existing operating system libraries. However, they have a larger file size (as all the necessary libraries are stored within it).

Dynamic UNIX programs have the advantage that they have a smaller file size. However, if the shared library is not present on the UNIX file system, or the shared library is present, but not the right version, the dynamic UNIX program won't run.

On the UNIX command line, you can determine whether any executable file is built with static or dynamic libraries.

Use this command: file .

For example:

% file payconfig.cgi
payconfig.cgi: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, stripped

Notice how the output states it's dynamically linked. This is not static. Another example:

% file sync
sync: ELF 32-bit MSB executable SPARC Version 1, statically linked, stripped

Notice how it says that it's statically linked.

You can determine what libraries a UNIX program is looking for when it runs. Use the ldd command:

% ldd payconfig.cgi => /usr/lib/ => /usr/lib/ => /usr/lib/

Related Articles

No related articles were found.


No attachments were found.

Visitor Comments

Article Details

Last Updated
13th of November, 2008

Would you like to...

Print this page  Print this page

Email this page  Email this page

Post a comment  Post a comment

 Subscribe me

Subscribe me  Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF

User Opinions

How would you rate this answer?

Thank you for rating this answer.