Linux Basics Practice Test: Static Libraries — Flashcards | Linux | FatSkills

Linux Basics Practice Test: Static Libraries — Flashcards

Fast review mode: answers are shown by default so you can skim quickly. Hide them if you want to self-test.

Static libraries in Linux are collections of object files that are copied into the final executable image during compilation. The linker links static libraries as the last step in the compilation process. 

Static libraries are reusable in multiple programs, but are locked into a program at compile time. Each process gets its own copy of the code and data. The final executable has no dependencies on the library at run time, so you don't need to carry along a copy of the library that is being used. 
 

Static libraries are created using the ar (archiver) program. For example, ar rcs my_library.a file1.o file2.o adds the object files file1.o and file2.o to the static library my_library.a. If my_library.a doesn't already exist, it will be created. Static libraries usually have a suffix of .a
 

You can also create a static library using the following command: gcc -c -Wall -Werror -Wextra *.c. 

The flags in this command have the following meanings:
-c
Compile and assemble, but do not link
-Wall, -Werro and -Wextra These aren't necessary but they are recommended to generate better code 

Static libraries are not relevant during runtime.

1 of 10 Ready
In Linux, the static library has the extension of
.a
Shortcuts
Prev Space Show / hide Next
Turn this into a study set.
Sign in with Google to save tricky questions to your reminder list and resume on any device.
Sign in with Google Free • no extra password