Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 1.07 KB

PreprocessorAndCompiler.md

File metadata and controls

22 lines (16 loc) · 1.07 KB

C Preprocessor and C Compiler

1. How to compile a C Program?

2. Static Lib and Shared Lib different?

Static library is linked into the program at compile time which means there is no additional run-time loading costs. Although it is added on app binaries size, it is able to ensure dependencies of the libraries are able to be met. Example with staticlib.a :

$ gcc main.o -o main staticlib.a

Static lib

Dynamic library can be loaded or unloaded its code at run-time. A program using a dynamic library only makes reference to code that it uses in the dynamic library. Example:

$ gcc -shared liba.o libb.o -o libtest.so
$ gcc main.c -o main -L -ltest