Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8439837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:06:54+00:00 2026-06-10T08:06:54+00:00

I was just experimenting with the static and dynamic library stuff. I made two

  • 0

I was just experimenting with the static and dynamic library stuff. I made two .c files (say file1.c, file2.c) and two .h files which contained some functions defined and declared in them respectively.

I also made a new .c which will be calling the functions in these above two described .c files.

I wanted to check the size of the executable I get if I use a shared library/ static library, so I made a static lib (libstat.a) and a shared lib (libshar.so) from the .o s of the files file1.c and file2.c.

On linking these libs to my main .c I find that the executable size is more in case of the dynamic lib. That is not expected, right? In case of use of shared lib the lib is loaded run time so why does it is having more size?

I am using the following commands:

static lib case

gcc -c file1.c file2.c

ar -cvq libstat.a file1.o file2.o

gcc -o ex1 mainprg.c -L . -lstat

dynamic/shared lib case

gcc -c -fpic file1.c file2.c

gcc -shared file1.o file2.o -o libshar.so

gcc -o ex2 mainprg.c -L . -lshar

I find that libshar.so has more size than libstat.o and ex2 has more than ex1. I expected this results to be reverse. Can somebody explain me the reason?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:06:56+00:00Added an answer on June 10, 2026 at 8:06 am

    How much more/less? I wouldn’t find it too surprising to see a little more space used for a dynamic binary over static if the stuff in the libraries is trivial. The dynamic binary needs to contain extra symbol information and other metadata to facilitate run-time linking. Much of that metadata can be left out when static linking, so if the functions and/or data in the library are fairly small, that might be what you’re seeing. For more substantial libraries, though, with a lot more code and data, or when you’re linking with a lot of different libraries, the binaries should be considerably smaller…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just experimenting with boost::pool to see if its a faster allocator for stuff
I've just been experimenting with the boost::function_types library recently, and I've come across a
Hi I've just started experimenting with .live and .die and having some great results
I was just experimenting and ended up with the following snippet: public static class
I am just experimenting something with jQuery. I have an image which fades into
I was experimenting with static cells, therefore I made a Table View and embedded
I'm just experimenting with mixing a native C++ (that uses MFC) static lib and
First sorry im a big beginner and just experimenting, and I made a similar
I just started experimenting with Aptana Jaxer server side javascript engine for my next
I've just started experimenting with WPF templates vs. styles and I'm not sure what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.