Make a static library and a dynamic library under Windows

Source: Internet
Author: User

One: Creation of a static library
  1. The new one in vc++6.0 is the Win32 Static Library project, followed by two options. Choose it according to your needs.
  2. The process of adding a specific class or function is like a standard project, creating a new class directly or adding a new
    . h (Example: MY.h) and. CPP (example: MY.cpp) files. Then write the implementation in it.
  3. When finished, the compilation generates a. lib file (for example: MY.lib generated) The file I generated is TEST.lib .
  4. Compile a problem, remove a long

  5. Prompt for error modification methods
II: Creation of dynamic libraries
  1. vc++6.0 in the new one for the Win32 Dynamic-link Library project, followed by three options. Choose it according to your needs.
  2. The process of adding a specific class or function is like a standard project, creating a new class directly or adding a new
    . h (Example: MY.h) and. CPP (example: MY.cpp) files. Then write the implementation in it.
  3. When finished, the compilation generates a. lib file (for example, MY.lib is generated).
Third: Static library use

Static libraries include. Lib and. h files

1, in the project to add a static library, there are two ways:

method One : Referenced in the project settings. Lib,project-setting-link-object/library Modules Tim
Add. lib; (need to set the correct reference path in tools/options)

method Two : Join Lib,project-add to Project-files directly in the project and select the correct. lib.

Issue 1: Link error after changing settings so

Method:

Join #pragma comment (lib, "MYTEST.lib")

Copy the two files to the appropriate folder in Use1.cpp and you are ready to run.

2. Include. h files in the project (you may need to set the correct reference path in tools/options)

3, the use of static library functions in the project;

Four: Dynamic library use

Dynamic link libraries typically include. Lib (export function),. H,.dll.

1, implicit links, similar to the use of static library, divided into three steps: Reference. lib, including the header file, using the export function;

2, dynamic loading, directly using LoadLibrary load the required dynamic library, and then specify the required export function, the effect
Rate is highest!

3. Compile link pass, run failed

Found the creation method is incorrect, modify the code as follows

Copy the MYTEST3.dll to debug and successfully

Study reference: http://wenku.baidu.com/view/47507393daef5ef7ba0d3ca6.html

Http://www.docin.com/p-65088206.html

Make a static library and a dynamic library under Windows

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.