2.4. Using Libraries with the GCC
Libraries are collections of reusable code, which can make coding easier and more effective. Understand library naming conventions and the distinction between static and dynamic linking. Link applications with static or dynamic libraries with GCC, and optimize with Link Time Optimization (LTO).
2.4.1. Library naming conventions 复制链接链接已复制到粘贴板!
System libraries require consistent naming. A library known as foo is expected to exist as file libfoo.so or libfoo.a. This convention is automatically understood by the linking input options of the GNU Compiler Collection (GCC), but not by the output options:
When linking against the library, the library can be specified only by its name foo with the
-loption as-lfoo:$ gcc ... -lfoo ...-
When creating the library, the full file name
libfoo.soorlibfoo.amust be specified.
Additional resources