amirassov
amirassov

Reputation: 81

c++: multiple copies of a static library in memory

I use a static library in the c++ program. Can memory stores multiple copies of the library? Or for one program, one copy of a static library?

Upvotes: 2

Views: 807

Answers (1)

n. m. could be an AI
n. m. could be an AI

Reputation: 120079

I use a static library in the c++ program

No you don't.

You are using a static library while linking a program, but a finished program contains no trace of the library as a separate entity. There are zero copies of the library in your program.

Your program contains copies of (some of) the object files that live in the static library. Once picked up by the linker, they are on equal standing with all other (non-shared) object files you use (e.g. the one that contains the main function). Having two copies of any of them would be like having two copies of main.

Upvotes: 6

Related Questions