About the. H,. Lib,. dll file

Source: Internet
Author: User

1. h file:

(1). h only makes declarations, and no code is generated after compilation. # include is equivalent to copying the. h file to. C;

(2) The function definition should be placed in. C, and. H should only be declared. Otherwise, repeated Function Definition errors will occur when multiple references are made;

(3) The C file is the minimum unit for the compiler to run. Each C file is compiled into an independent target file (Binary );--OBJ file

(4) The connector is based on the target file. It migrates functions and variables of one or more target files to generate the final executable file;

TIPS:

(1) No errors will be reported during compilation only when the declaration is not defined;

(2) The function declared by. h must be able to find the corresponding target file (The. c file compiled binary file) in the compiler search path ),Is it in lib or DLL format?To hide the function source code while providing functions.

2. Lib File

(1) Currently, there are two types of libraries suffixed with Lib: static library and dynamic library) import library );

(2) The static library is a package of one or more OBJ files, so someone simply calls the process of generating lib from the OBJ file archive, that is, merging it together. For example, if you link a static library, if there is a mistake in it, it will accurately find which obj is wrong, that is, static Lib is only a shell;

(3) The static library itself contains the actual execution code, symbol table, and so on. The actual Execution Code of the imported database is in the dynamic library, and the imported database only contains the address symbol table, make sure that the program finds some basic address information of the corresponding function.

3. dll file

(1) Static call (implicit call): the dynamic library usually has the corresponding import and export warehouse, so that the program can load the dynamic link library statically, you only need to call the function by following the declaration of the header file function interface after the link is imported to the database;

(2) dynamic call (explicit call): Use loadlibrary to call the DLL file, and then manually getprocaddress to obtain the corresponding function;

(3) When the program is running, the operating system loads the dynamically linked library files into the memory and maps them to the address space of the program, this ensures that the program can normally call the functions in the library file. At the same time, the operating system ensures that when the program runs on multiple instances, only one dynamic link library is copied to the memory, that is, the dynamic link library is shared at runtime.

 

Related Article

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.