Every C++ programmer has probably, at one time or another, written a linked list or set, searching and sorting routines. Most likely, the programmer has re-invented the wheel for every new user-defined data type. Design changes are not easy to implement in such cases. Maintaining such code is not very easy, either.
If the common programming components were part of the C++ language, programmers would not need to "re-invent the wheel."
Finally, the C++ language provides you with general purpose components for common programming tasks through the Standard C++ Library. The Standard C++ Library provides powerful and flexible containers, programmable algorithms, and other components that are efficient and extensible.
The facilities provided by the Standard C++ Library are as follows:
The Standard C++ Library also incorporates the Standard C Library.
Microsoft® Visual C++® version 4.2 provides the Standard C++ Library facilities through included files and associated static and dynamic libraries.
A C++ program can use the different components of the Standard C++ Library by including the required header and linking with the appropriate static or dynamic library.
Tables 1 and 2 list all the Standard C++ Library headers and the associated static and dynamic libraries provided by Visual C++ 4.2.
ALGORITHM | BITSET | CASSERT | CCTYPE |
CERRNO | CFLOAT | CISO646 | CLIMITS |
CLOCALE | CMATH | COMPLEX | CSETJMP |
CSIGNAL | CSTDARG | CSTDDEF | CSTDIO |
CSTDLIB | CSTRING | CTIME | CWCHAR |
CWCTYPE | DEQUE | EXCEPTION | FSTREAM |
FUNCTIONAL | IOMANIP | IOS | IOSFWD |
IOSTREAM | ISTREAM | ITERATOR | LIMITS |
LIST | LOCALE | MAP | MEMORY |
NEW | NUMERIC | OSTREAM | QUEUE |
SET | SSTREAM | STACK | STDEXCEPT |
STREAMBUF | STRING | STRSTREAM | TYPEINFO |
UTILITY | VALARRAY | VECTOR | XIOSBASE |
XLOCALE | XLOCINFO | XLOCMON | XLOCNUM |
XLOCTIME | XMEMORY | XSTDDEF | XSTRING |
XTREE | XUTILITY |
Note: The Standard C++ Library headers do not have an .h extension. This is in accordance with the latest C++ working papers.
Visual C++ 4.2 includes the following static and dynamic libraries (in addition to the Microsoft Class Library [MFC]):
Note: With Visual C++ 4.2, the iostream support has been pulled out of the C run-time library and exists as an independent entity. Now Visual C++ has the following libraries:
Library types and related compiler switches | Basic C run-time library | Standard C++ Library | Old iostream library |
Single Threaded (ML) | LIBC.LIB | LIBCP.LIB | LIBCI.LIB |
Multithreaded (MT) | LIBCMT.LIB | LIBCPMT.LIB | LIBCIMT.LIB |
Multithreaded DLL version (MD) | MSVCRT.LIB (import library for MSVCRT.DLL) | MSVCPRT.LIB (also uses MSVCRT.DLL) | MSVCIRT.LIB (import library for MSVCIRT.DLL) |
Debug Single Threaded (MLd) | LIBCD.LIB | LIBCPD.LIB | LIBCID.LIB |
Debug Multithreaded (MTd) | LIBCMTD.LIB | LIBCPMTD.LIB | LIBCIMTD.LIB |
Debug Multithreaded DLL (MDd) | MSVCRTD.LIB (import library for MSVCRTD.DLL) | MSVCPRTD.LIB (also uses MSVCRTD.DLL) | MSVCIRTD.LIB (import library for MSVCIRTD.DLL) |
Case 1. Consider the following sample C++ program where test.cpp uses the Standard C++ Library iostream to print "Hello World".
// test.cpp
#include <iostream>
void main() {
cout << "Hello World"
<< endl ;
}
Building test.cpp using | Will cause test.cpp to link with |
cl /ML /GX test.cpp | LIBC.LIB, LIBCP.LIB |
cl /MLd /GX test.cpp | LIBCD.LIB, LIBCPD.LIB |
cl /MT /GX test.cpp | LIBCMT.LIB, LIBCPMT.LIB |
cl /MTd /GX test.cpp | LIBCMTD.LIB, LIBCPMTD.LIB |
cl /MD /GX test.cpp | MSVCRT.LIB, MSVCPRT.LIB |
cl /MDd /GX test.cpp | MSVCRTD.LIB, MSVCPRTD.LIB |
In Case 1, test.cpp used the Standard C++ Library input/output component to print "Hello World." The program just includes the Standard C++ Library header <iostream>. When compiling the program, specify a run-time library option: /ML[d],/MT[d], or /MD[d]. The program will then link with a basic run-time library (for example, LIBC.LIB with the /ML option) and a Standard C++ Library (for example, LIBCP.LIB with the /ML option). The /GX option enables exception handling. Exception handling must be enabled for any programs that use the Standard C++ Library.
It is important to remember that starting with Visual C++ 4.2, a C++ program, depending on the run-time library compiler option specified (/ML[d],/MT[d], or /MD[d]), will always link with one Basic C run-time library and, depending on headers included, will link with either a Standard C++ Library (as in the case 1), an old iostream library (as in Case 3), or neither (as in Case 2).
Case 2. Consider the following sample program:
// test.cpp void
main()
{
}
Building test.cpp using | Will cause test.cpp to link with |
cl /ML test.cpp | LIBC.LIB |
cl /MLd test.cpp | LIBCD.LIB |
cl /MT test.cpp | LIBCMT.LIB |
cl /MTd test.cpp | LIBCMTD.LIB |
cl /MD test.cpp | MSVCRT.LIB |
cl /MDd test.cpp | MSVCRTD.LIB |
Case 3. Consider the following sample program:
// test.cpp
#include <iostream.h>
void main()
{
}
Building test.cpp using | Will cause test.cpp to link with |
cl /ML test.cpp | LIBC.LIB, LIBCI.LIB |
cl /MLd test.cpp | LIBCD.LIB, LIBCID.LIB |
cl /MT test.cpp | LIBCMT.LIB, LIBCIMT.LIB |
cl /MTd test.cpp | LIBCMTD.LIB, LIBCIMTD.LIB |
cl /MD test.cpp | MSVCRT.LIB, MSVCIRT.LIB |
cl /MDd test.cpp | MSVCRTD.LIB, MSVCIRTD.LIB |