Static Library Packaging

Source: Internet
Author: User

static libraries (target files: binaries,. o,.a) Packaging: There are two conditions for using a static library:

    1. Include the library file in

    2. 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

    1. Code protection (Cannot see the original code)

    2. Low maintenance costs

    3. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.