Relationship Between. OBJ,. Lib,. dll, And. h

Source: Internet
Author: User
Sunlet (big winner) 22:42:00 in the VC/mfc/basic class questions

1 .. How is the relationship between OBJ,. Lib,. dll, And. h? What are the differences in calling methods when using them?
2. For how to create a. Lib file by yourself, please take the process as an example. Thank you!
3. How to Use the obj. file in the project file.

1 floor Holly ()The score is returned at 02:34:00. 80

1.
OBJ: the binary code format corresponding to CPP. It is not relocated!
Lib: a collection of several OBJ objects. It is essentially the same as obj!
DLL: it is a binary code that can be actually run. It has the locating code!
H: It is a header file or source code, because when # include is used in CPP, the content of the included file will be expanded in CPP!
Top

2 floor Holly ()The score is 0 at 02:45:00.

2.
In VC ++, Appwizard can be used to create a lib project,
File-> New-> projects-> Win32 static library;
Add your source file to the project!
Project-> Add to projects-> files;

3. Add the OBJ file to the project!
Project-> Add to projects-> files; select your obj file;
Top

Holly () on the third floor ()The score is 0 at 02:55:00.

1.
When using OBJ, there is no essential difference between OBJ and Lib. Lib is obj. You can use OBJ wherever you use Lib;
DLL is a dynamic Connection Library and dynamically loaded during runtime, while Lib is a static Connection Library, which is equivalent to binary code compiled by the program without link locating! (An expression of OBJ)
The H file is used to compile the prototype declaration of functions (classes and variable types). Generally, the use of DLL, Lib, and OBJ requires the combination of the H file to obtain the prototype declaration of binary code!
Of course, you can also use getprocaddress to avoid using h文es when using DLL! Top

4 floor Holly ()The score is 0 at 03:25:00.

Note:
When using DLL, an additional Lib is also used to indicate the DLL extraction table. The information is equivalent to only the declared part of an OBJ, and there is no function body. Top

Sunlet on the fifth floor (big winner)The score is 0 at 11:24:00.

How to make my lib as the Lib of the compiler and automatically add it to my project without adding files to projecttop every time

6 floor Holly ()The score is 0 at 11:52:00.

No way! You must add it yourself each time!
The best case is in tools-> options... -> in directories, add the path settings of include, library, and source files to the directory of your code library. for debugging convenience, output different names for debug and release respectively, for example, add a d after the output file of the debug version.
However, you must set the project-> Settings-> link-> Object/library modules for each project you use: add the name of the required database in the column (no path required )! Top

Sunlet on the 7th floor (big winner)The score is 0 at 21:37:00.

Thank you very much for the help of Holly. I encountered the following problems when I was doing Lib. Please explain:
I have compiled a lib (foxreader. Lib) that supports MFC. When the MFC program calls it, there are the following warning,
A single program can still be executed. Could you tell me how to remove these warnings.
Linking...
Link: Warning lnk4098: defaultlib "mfc42.lib" conflicts with use of other libs; Use/nodefaultlib: Library
Link: Warning lnk4098: defaultlib "mfcs42.lib" conflicts with use of other libs; Use/nodefaultlib: Library
Link: Warning lnk4098: defaultlib "msvcrt. lib" conflicts with use of other libs; Use/nodefaultlib: Library
Foxclass.exe-0 error (s), 3 warning (s)
Top

8 floor Holly ()The score is 0 at 23:36:00.

There is no need to remove this warning!
This is because your foxreader. Lib also uses the Lib file of the same MFC, and linker automatically skips the information given by repeated links!
Top

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.