static libraries (target files: binaries,. o,.a) Packaging: There are two conditions for using a static library:
Include the library file in
Include header file
Note: The main function cannot be in a library file
In Linux, the static link library ends with. A, and the dynamic link library ends with. So.
In Windows, the static link library ends with a. Lib, and the dynamic-link library ends with a. dll.
Static library packaging is mainly the creation of multiple. o files linked files, with the following advantages
Code protection (Cannot see the original code)
Low maintenance costs
Protection period can be set in static library (eg: Get current time and 2019 comparison, exit if greater than)
Makefile's writing:
1. PHONY:LIBMYSEM.A 2 libmysem.a:comm.o 3 ar RCS [email protected] $^ 4 comm.o:comm.c 5 gcc-c $< 6. Phony:clean 7 Clean:8 rm-f libmyset.a COMM.O
$< means to take the dependency table file out to the Gcc-c command.
You can use the static library, create a new directory, copy the LIBMYSET.A and comm.h files to this directory, which is the two conditions for using a static library. But now still can't find the library file, citation we usually use when the system files in the environment variable path defined path, so can be found. Next, modify the makefile file to add-i/lib (can find the header file)-l/lib (search Path)-lmyset (which library under one path).
This article is from the "Small Stop" blog, please be sure to keep this source http://10541556.blog.51cto.com/10531556/1764133
Static Library Packaging