In-depth analysis of Windows and Linux dynamic library application Similarities and Differences

Source: Internet
Author: User
In-depth analysis of Windows and Linux dynamic library application similarities and differences-general Linux technology-Linux programming and kernel information, the following is a detailed description. Abstract: The concept of dynamic library exists in Windows and Linux systems. Dynamic library can effectively reduce the program size and save space, improve efficiency, increase program scalability, and facilitate modular management.

However, because the dynamic libraries of different operating systems have different formats, dynamic library programs need to be transplanted when calling different operating systems. This article analyzes and compares the two types of dynamic operating system library technology, and provides the methods and experience of porting the dynamic library compiled by Visual C ++ to Linux.

1. Introduction

Dynamic Library (DLL) is a frequently used technology in programming. It aims to reduce the program size, save space, improve efficiency, and have high flexibility.

It is easier to upgrade the software version by using the dynamic library technology. Unlike Static Link Library, functions in the dynamic Library are not part of the execution program, but loaded as needed, its Execution Code can be shared among multiple programs at the same time.

This method can be used in both Windows and Linux operating systems for software design, but their calling methods and programming methods are different. This article first analyzes the dynamic library calling methods and programming methods commonly used in these two operating systems, and then analyzes and compares the differences between the two methods, finally, based on the actual porting experience, this article introduces how to port the Windows dynamic library compiled by VC ++ to Linux.

2. Dynamic library technology

2.1 Windows dynamic library technology

Dynamic Link Library is an important technical means for Windows applications to share resources, save memory space, and improve usage efficiency. Common dynamic libraries include external functions and resources, and some dynamic libraries only contain resources, such as Windows Font Resource files, which are called resource dynamic link libraries. Generally, the dynamic library uses. dll,. drv,. fon, and so on as the suffix.

The corresponding windows static library usually ends with. lib, and Windows itself implements some major system functions in the form of dynamic library modules.

The Windows dynamic library is loaded into the virtual space of the process at runtime, and the memory allocated from the virtual address space of the calling process becomes part of the calling process. DLL can only be accessed by the thread of the process. The DLL handle can be used by the calling process, and the call Process Handle can be used by the DLL.

The DLL module contains various export functions to provide external services. A dll can have its own data segment but does not have its own stack. It uses the same stack mode as the application that calls it. a dll has only one instance in the memory; DLL implements code encapsulation. The compilation of DLL has nothing to do with the specific programming language and compiler. You can use DLL to implement mixed language programming. Any object (including variables) created by the code in the DLL function is owned by the thread or process that calls it.
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.