简体   繁体   中英

What does a GCC compiled static library contain?

My application links against libsamplerate.a. I am doing this to make distributing the final binary easier.

I am worried that perhaps the code inside the .a file depends on some other libraries I also will need to distribute.

But if it doesn't I am worried I am bloating up my application too much by including multiple copies of eg. libc.

What exactly will be inside libsamplerate.a? Just libsamperate's bytecode? Or more?

A .a file is basically just a bundle of .o files. You can demonstrate this using the ar tool.

For instance, to display the contents of your library:

ar -t libsamplerate.a

To create a .a file from scratch:

ar -r tim.a *.txt

A static library is just a collection of object files. When you compile a program against a static library, the object code for the functions used by your program is copied from the library into your executable. Linking against a static library will not cause any functions outside that library to be included in your code.

Just the object code for libsamplerate. Statically linking against a single library doesn't make all libraries linked statically; that would be Bad.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM