C and C + + runtime libraries

Source: Internet
Author: User
Tags function prototype

First, the dynamic library under Windows

1. Static function library

The name of such a library is generally libxxx.lib; the file compiled by the static function library is larger because all the data of the library is integrated into the target code, and his advantages are obvious, that is, the compiled execution sequence does not require external library support. Because all the functions used are already compiled. This, of course, will also be a disadvantage, because if the static library changes, then your program must be recompiled.

2. Dynamic Function Library

The name of such a library is generally libxxx.lib + libxxx.dll; relative to the static function library, the dynamic function library is not compiled into the target code when it is compiled, and your program executes to the relevant function to invoke the corresponding function in the library, so the dynamic function library produces less executable files. Since the library is not integrated into your program, it is applied and invoked dynamically while the program is running, so you must provide the appropriate library in the running environment of the program. The change of dynamic function library does not affect your program, so the upgrade of dynamic function library is more convenient.

Two C, C + + Runtime Library

In order to improve the development efficiency of C language, the C standard defines a series of commonly used functions called C library functions. The C standard simply defines a function prototype and does not provide an implementation. This task is therefore left to the various compilers that support the C language standard. Each compiler typically implements a superset of standard C, called the C Runtime Library (C run time Libray), or CRT. For the VC + + compiler, it provides a CRT library that supports standard C functions defined by the C standard, as well as some specifically designed functions for Windows systems.

Similar to the C language, C + + also defines its own standards, while providing the relevant support libraries, which we call the C + + runtime library or C + + standard library.

Due to C + + 's compatibility, the C + + standard library includes an IO stream and a standard Template Library STL.

VC + + Perfect support for the C and C + + standards, so also in accordance with C and C + + standard defined function prototype implementation of the above run-time library. In order to facilitate the use of customers with different needs, VC + + has implemented the dynamic link library DLL version and the static library Lib version. At the same time, in order to support the program debugging and do not affect the performance of the program, but also provide a corresponding debug version. The name of the debug version adds the letter D after the release version name.

DLL versions and LIB versions are available for the C run-time libraries crt,vc6.0, VC2005, VC2008, and VC2010. The Lib version of the CRT libraries provided by each of the above compilers are implemented in LIBCMT.lib. The corresponding debug version name is LIBCMTD.lib.

The DLL version name differs depending on the compiler and can be distinguished from the name.

VC6. The version of the DLL used by the CRT library is implemented in MSVCRT.DLL, corresponding to the debug version of MSVCRTD.DLL.

The DLL version of the CRT library used by VC2005 is implemented in MSVCR80.DLL, corresponding to the debug version of MSVCR80.DLL.

The DLL version of the CRT library used by VC2008 is implemented in MSVCR90.DLL, corresponding to the debug version of MSVCR90D.DLL.

The DLL version of the CRT library used by VC2010 is implemented in MSVCR100.DLL, corresponding to the debug version of MSVCR100D.DLL.

The C + + standard is compliant, but the VC versions implement the C standard library used by the C + + compiler with the C runtime library used by the C compiler, which uses the same runtime library.

DLL versions and LIB versions are also available for IO streams and stl,vc6.0, VC2005, VC2008, and VC2010 in the C + + standard library.
The LIB version is implemented in Libcpmt.lib, and the corresponding debug version is libcpmtd.lib.

The DLLs implemented by different versions of the compiler are not the same.
VC6. The DLL version of the C + + class library used is implemented in MSVCP60.DLL, corresponding to the debug version of MSVCP60D.DLL.

The DLL version of the C + + class library used by VC2005 is implemented in MSVCP80.DLL, corresponding to the debug version MSVCP80.DLL.

The DLL version of the C + + class library used by VC2008 is implemented in MSVCP90.DLL, corresponding to the debug version MSVCP90D.DLL.

The DLL version of the C + + class library used by VC2010 is implemented in MSVCP100.DLL, corresponding to the debug version MSVCP100D.DLL.

In each version of the compiler, we can configure options to set the type of C and C + + runtime libraries that the program uses. such as (other versions of the compiler are similar):

MT option: Link the Lib version of the C and C + + runtime libraries. When you link, the C and C + + runtime libraries are integrated into your program's code, and the program volume becomes larger.

MTD option: The Debug version of Lib.

MD option: Use the DLL version of the C and C + + runtime libraries, so that when the program runs dynamically load the corresponding DLL, the program volume will be reduced, the disadvantage is that the system does not have a corresponding DLL when the program cannot run.

MDD options: Represents a debug version that uses a DLL.

3. Advantages and Disadvantages

The static version must copy the C and C + + runtime libraries to the target program, so the resulting executables will be larger. At the same time, for large software with multiple modules, if each module chooses static link C, C + + runtime, there will be multiple runtimes when the program runs. There is a duplicate definition of the problem when linking.

Using the DLL version of the C and C + + runtime libraries, the program dynamically loads the corresponding DLLs at run time. Program volume is smaller, but a big problem is that once the corresponding DLL is not found, the program will not run. Assuming that you use VC6.0 and choose to build with the MD option, it is likely that MSVCRT.DLL or MSVCP60.DLL could not be found when the user uses VC2005 to use the DLL.

C and C + + runtime libraries

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.