. OBJ,. Lib,. dll,. EXE relationship

Source: Internet
Author: User

. OBJ,. Lib,. dll,. EXE relationship

Lib corresponds to DLL.
Lib is a static library file, and DLL is a dynamic library file.
The so-called static is to extract the required content from the link and arrange it into your EXE file. Lib is no longer needed for running your EXE later.
The so-called dynamic is that when the EXE runs, it depends on the functions provided in the DLL. Without this DLL, your EXE cannot run.
Lib, DLL, and exe are all final target files and are final products. C/C ++ is the source code. In the source code and the final target file, the transition is the intermediate code obj. In fact, you cannot get the target file at one time because the intermediate code is required. For example, an EXE requires many CPP files to be generated. The compiler can only compile one CPP file at a time. In this way, the compiler will compile a CPP into obj. When all required CPP files are compiled into OBJ, the compiler will link them to the required exe, if any obj is missing, the link of the EXE will fail.

1. OBJ stores the compiled code and data with a name. Therefore, an unresolved external symbol will appear during the connection. After an EXE is connected, the name concept does not exist. Only the address is available. Lib is a combination of a bunch of obj.
2. Theoretically, but Lib is usually used in practice.
3. the compiler will link some frequently-used libraries by default. You must specify other libraries by yourself.

The difference between lib and DLL is attached.

(1) Lib is required during compilation and DLL is required during runtime.
If you need to complete source code compilation, it is enough to have Lib.
If dynamic connection is also enabled, DLL is enough.
In the development and debugging stages, it is best to have both.
(2) common dynamic library programs include lib files and DLL files. The LIB file must be connected to the application during the compilation period, and the DLL file will be called only during the runtime. If there is a DLL file, the corresponding lib file is generally some index information, the specific implementation is in the DLL file. If only the Lib file is available, the Lib file is statically compiled and the indexes and implementations are all included. The advantage of static compiling lib files is that dynamic libraries are no longer needed during installation. However, there are also some disadvantages, that is, the application is relatively large and the flexibility of the dynamic library is lost. During version upgrade, new applications must be released at the same time.
(3) In the case of a dynamic library, there are two files, one is imported into the database (. lib) file. One is a DLL file. The imported file contains the name and location of the function exported by the DLL. The dll contains the actual function and data, the application uses the Lib file to link to the required DLL file. The functions and data in the library are not copied to the executable file. Therefore, in the executable file of the application, stores not the called function code, but the memory address of the function to be called in the DLL, in this way, when one or more applications are running, the program code is linked to the called function code, thus saving memory resources. From the above description, we can see that the DLL and. Lib files must be released along with the application, otherwise the application will produce errors.

Reprinted from: http://blog.csdn.net/yysdsyl/archive/2009/09/26/4593591.aspx

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.