Win32 API: C Run-time Libraries - 2020
Bookmark and Share
ms_icon.png

C Run-time Libraries

The Microsoft run-time library provides routines for programming for the Microsoft Windows operating system. These routines automate many common programming tasks that are not provided by the C and C++ languages.

The C standard defines a set of functions that an implementation must supply. Microsoft added various other functions for compatibility or to provide capabilities the standard functions don't address. In most cases, it will also contain quite a few "internal" functions that are used by the compiler but they are not normally exposed to the end user.

AS we can see from the table below, there are some naming conventions used:
For example, libcmt is implementations of the C standard library provided with Microsoft's compiler. They provide both "debug" and "release" versions of three basic types of libraries: single-threaded (always statically linked), multi-threaded statically linked, and multi-threaded dynamically linked.

In the name "libcmt", "libc" is the (more or less) traditional name for the C library. The "mt" means "multi-threaded". A "debug" version would have a "d" added to the end, giving "libcmtd".


C Run-time Libraries

C Run-time Library Description Compiler option Preprocessor Directives
libc.lib Single-threaded, static link /ML  
libcmt.lib Multithreaded, static link /MT _MT
msvcrt.lib Multithreaded, dynamic link (import library for MSVCR70.DLL).
To use the Standard C++ Library, we need MSVCP70.DLL.
/MD _MT, _DLL
libcd.lib Debug Single-threaded, static link /MLd _DEBUG
libcmtd.lib Debug Multithreaded, static link /MTd _DEBUG, _MT
msvcrtd.lib Debug Multithreaded, dynamic link (import library for MSVCR70D.DLL) /MDd _DEBUG, _MT, _DLL
  • If we link our program from the command line without a compiler option that specifies a C run-time library, the linker will use libc.lib by default.
  • When we build a release version of our project, one of the basic C run-time libraries (libc.lib, libcmt.lib, and msvcrt.lib) is linked by default, depending on the compiler option you choose (single-threaded, multithreaded, or dll).
  • For a typical C and C++ program, by just providing the proper header files let the compiler determine for us which libraries are appropriate to be linked.