user5023960
user5023960

Reputation:

why executable is smaller than the library which is statically linked with application project?

I have created windows application project in visual studio. OpenSSL library (Size: 15Mb) is statically linked with application project.

But, Still size of application (executable file) .exe file ~ 2 MB only.

How is it possible? Can anyone explain me how linker do that ?

Upvotes: 2

Views: 491

Answers (1)

Codo
Codo

Reputation: 78815

During linking, the linker will only pick the code from the OpenSSL library that is needed by your application. It will not include the entire OpenSSL library. Therefore, your executable can be considerably smaller than the library.

Basically, a static library is just a container of object files. Each object files contains the code for a single compilation unit.

Upvotes: 2

Related Questions