A static library(.a) is a library that can be linked directly into the final executable produced by the linker,it is contained in it and there is no need to have the library into the system where the executable will be deployed.
A shared library(.so) is a library that is linked but not embedded in the final executable, so will be loaded when the executable is launched and need to be present in the system where the executable is deployed.
A '.so' file requires -fPIC option to make 'Position Independent Code' in compilation as: gcc -fPIC -c helloworld.c
A dynamic link library on windows(.dll) is like a shared library(.so) on linux but there are some differences between the two implementations that are related to the OS (Windows vs Linux) :
A DLL can define two kinds of functions: exported and internal. The exported functions are intended to be called by other modules, as well as from within the DLL where they are defined. Internal functions are typically intended to be called only from within the DLL where they are defined.
An SO library on Linux doesn't need special export statement to indicate exportable symbols, since all symbols are available to an interrogating process.
정적 라이브러리 vs. 동적 라이브러리
- Static libraries (.a files): At link time, a copy of the entire library is put into the final application so that the functions within the library are always available to the calling application
- Shared objects (.so files): At link time, the object is just verified against its API via the corresponding header (.h) file. The library isn't actually used until runtime, where it is needed.
The obvious advantage of static libraries is that they allow the entire application to be self-contained, while the benefit of dynamic libraries is that the ".so" file can be replaced (ie: in case it needs to be updated due to a security bug) without requiring the base application to be recompiled.
Unix system에선 컴파일 된 object를 .out 파일로, 정적 라이브러리를 .a 파일로, 동적 라이브러리를 .so 파일로 생성하며,
Windows system에선 컴파일 된 object를 .o 파일로, 정적 라이브러리를 .lib 파일로, 동적 라이브러리를 .dll 파일로 생성한다.
(사실 만들어지는 과정의 결과에 따른 것이지, 보여지는 확장자 자체는 의미 없다)
'Work' 카테고리의 다른 글
스트레스 여정이 다시 시작되다 (0) | 2022.04.19 |
---|---|
글로벌 기업들의 넌글로벌 태도 (0) | 2022.04.08 |
Emulation vs. Simulation (0) | 2022.03.18 |
2132년 (0) | 2022.01.17 |
회사 품질이 나아지지 않던 이유 (0) | 2021.12.20 |