[MSDN文章CP]库的一些相关内容
========================================================================
[MSDN]中对“库”的使用介绍文章:
| 
 INFO: What Are the C/C++ Libraries My Program Would Link With?  | 
Q154753
The information in this article applies to:
Microsoft Visual C++, 32-bit Enterprise Edition, versions 4.2, 5.0
Microsoft Visual C++, 32-bit Professional Edition, versions 4.2, 5.0
===========================================================================
SUMMARY
This article describes the default libraries LIBC[D].LIB, LIBCMT[D].LIB, LIBCI[D].LIB, LIBCIMT[D].LIB, LIBCP[D].LIB, LIBCPMT[D].LIB, MSVCRT[D].LIB, MSVCIRT[D].LIB, and MSVCPRT[D].LIB that a program will link with when built using Visual C++.
MORE INFORMATION
When you build a release (or debug) version of your project in Visual C++, one of the basic C Runtime libraries (LIBC[D].LIB, LIBCMT[D].LIB, and MSVCRT[D].LIB) is linked by default, depending on the compiler option you choose (single-threaded <ML[d]>, multithreaded <MT[d]>, or multithreaded DLL<MD[d]>). A library from the Standard C++ Library or one from the old iostream library may also be linked depending on the headers you use in your code. For example, consider the following cases:
Case 1: Sample program test1.cpp
 
// test1.cpp
void main()
{
} 
If you build test.cpp using the /ML (or /MLd, for a debug build) compiler option, your program will link with LIBC.LIB (or LIBCD.LIB, for debug build), in addition to other libraries.
If you build test.cpp using the /MT (or /MTd, for a debug build) compiler option, your program will link with LIBCMT.LIB (or LIBCMTD.LIB, for debug build), in addition to other libraries.
If you build test.cpp using the /MD (or /MDd, for a debug build)compiler option, your program will link with MSVCRT.LIB (or MSVCRTD.LIB, for debug build), in addition to other libraries. In this case, your program will be dependent on MSVCRT.DLL (or MSVCRTD.DLL for debug build).
Case 2: Sample program test2.cpp
 
   // test2.cpp
   #include <iostream>
   void main()
   {
   } 
If you build test.cpp using the /ML (or /MLd, for a debug build) compiler option, your program will link with LIBC.LIB (or LIBCD.LIB, for debug build) and LIBCP.LIB (or LIBCPD.LIB, for debug build), in addition to other libraries.
If you build test.cpp using the /MT (or /MTd, for a debug build) compiler option, your program will link with LIBCMT.LIB (or LIBCMTD.LIB, for debug build) and LIBCPMT.LIB (or LIBCPMTD.LIB, for debug build), in addition to other libraries.
If you build test.cpp using the /MD (or /MDd, for a debug build) compiler option, your program will link with MSVCRT.LIB (or MSVCRTD.LIB, for debug build) and MSVCPRT.LIB (or MSVCPRTD.LIB, for debug build), in addition to other libraries. For Visual C++ 6.0, your program will be dependent on MSVCRT.DLL and MSVCP60.DLL (or MSVCRTD.DLL and MSVCP60D.DLL for debug build). For Visual C++ 5.0, your program will be dependent on MSVCRT.DLL and MSVCP50.DLL (or MSVCRTD.DLL and MSVCP50D.DLL for debug build). For Visual C++ 4.2, your program will be dependent on MSVCRT.DLL (or MSVCRTD.DLL for debug build) and MSVCPRT.LIB (or MSVCPRTD.LIB, for debug build).
Case 3: Sample program test3.cpp
 
// test.cpp
#include <iostream.h>
void main()
{
} 
If you build test.cpp using the /ML (or /MLd, for a debug build) compiler option, your program will link with LIBC.LIB (or LIBCD.LIB, for debug build) and LIBCI.LIB (or LIBCID.LIB, for debug build), in addition to other libraries.
If you build test.cpp using the /MT (or /MTd, for a debug build) compiler option, your program will link with LIBCMT.LIB (or LIBCMTD.LIB, for debug build) and LIBCIMT.LIB (or LIBCIMTD.LIB, for debug build), in addition to other libraries.
If you build test.cpp using the /MD (or /MDd, for a debug build) compiler option, your program will link with MSVCRT.LIB (or MSVCRTD.LIB, for debug build) and MSVCIRT.LIB (or MSVCIRTD.LIB, for debug build) in addition to other libraries. In this case, your program will be dependent on MSVCRT.DLL (or MSVCRTD.DLL for debug build) and MSVCIRT.DLL (or MSVCIRTD.DLL for debug build).
Headers determine whether the Standard C++ libraries, old iostream libraries, or neither will be linked. Compiler options (/ML[d], /MT[d], /MD[d]) determine which version of the libraries single-threaded, multithreaded, or multithreaded DLL is to be linked by default. 
NOTE: It may seem that headers without the ".h" extension are Standard C++ headers and that headers with the ".h" extension are C Runtime headers or old iostream headers. This is not true. As explained below, the files <useoldio.h> and <use_ansi.h> determine the libraries your application will link with. 
Actually, there are two header files, <useoldio.h> and <use_ansi.h>, that contain #pragmas. The #pragmas force either the old iostream library or the Standard C++ library to be linked in by default. 
The header file <useoldio.h> contains #pragma statements, which force the old iostream library to be linked in.All old iostream headers include <useoldio.h>. So, if you include any old iostream header in your application, the old iostream library will be linked by default. The following table lists all the header files that include <useoldio.h>.  
   Old iostream Headers
   --------------------
   FSTREAM.H   IOMANIP.H
   IOS.H       IOSTREAM.H
   ISTREAM.H   OSTREAM.H
   STDIOSTR.H  STREAMB.H
   STRSTREA.H 
The header file <use_ansi.h> contains #pragma statements that force the Standard C++ Library to be linked in. All Standard C++ Headers include <use_ansi.h>. So if you include any Standard C++ header in your application, the Standard C++ library will be linked by default. The following table lists all the header files that include <use_ansi.h>.
 
   Standard C++ Headers
   ------------------------------------------------------
   ALGORITHM    BITSET     COMPLEX    DEQUE
   FSTREAM    FUNCTIONAL   IOMANIP    IOS
   IOSFWD      IOSTREAM    ISTREAM    ITERATOR
   LIMITS      LIST        LOCALE     MAP
   MEMORY      NUMERIC     OSTREAM    QUEUE
   SET         SSTREAM     STACK      STDEXCEPT
   STREAMBUF   STRING      STRSTREAM  TYPEINFO
   UTILITY     VALARRAY    VECTOR     XIOSBASE
   XLOCALE     XLOCINFO    XLOCMON    XLOCNUM
   XLOCTIME    XMEMORY     XSTRING    XTREE
   XUTILITY    YMATH.H 
You cannot mix calls to the old iostream library and the new Standard C++ Library in Visual C++ 4.2.
Summary Table
------------------------------------------------------------------
| Compile   Old        New IOStream   Libraries                  |
| Option    IOStream   or STL         Linked With                |
|================================================================|
| /ML       No         No             LIBC.LIB                   |
|----------------------------------------------------------------|
| /MLd      No         No             LIBCD.LIB                  |
|----------------------------------------------------------------|
| /MT       No         No             LIBCMT.LIB                 |
|----------------------------------------------------------------|
| /MTd      No         No             LIBCMTD.LIB                |
|----------------------------------------------------------------|
| /MD       No         No             MSVCRT.LIB                 |
|----------------------------------------------------------------|
| /MDd      No         No             MSVCRTD.LIB                |
|----------------------------------------------------------------|
| /ML       No         Yes            LIBC.LIB,    LIBCP.LIB     |
|----------------------------------------------------------------|
| /MLd      No         Yes            LIBCD.LIB,   LIBCPD.LIB    |
|----------------------------------------------------------------|
| /MT       No         Yes            LIBCMT.LIB,  LIBCPMT.LIB   |
|----------------------------------------------------------------|
| /MTd      No         Yes            LIBCMTD.LIB, LIBCPMTD.LIB  |
|----------------------------------------------------------------|
| /MD       No         Yes            MSVCRT.LIB,  MSVCPRT.LIB   |
|----------------------------------------------------------------|
| /MDd      No         Yes            MSVCRTD.LIB, MSVCPRTD.LIB  |
|----------------------------------------------------------------|
| /ML       Yes        No             LIBC.LIB,    LIBCI.LIB     |
|----------------------------------------------------------------|
| /MLd      Yes        No             LIBCD.LIB,   LIBCID.LIB    |
|----------------------------------------------------------------|
| /MT       Yes        No             LIBCMT.LIB,  LIBCIMT.LIB   |
|----------------------------------------------------------------|
| /MTd      Yes        No             LIBCMTD.LIB, LIBCIMTD.LIB  |
|----------------------------------------------------------------|
| /MD       Yes        No             MSVCRT.LIB,  MSVCIRT.LIB   |
|----------------------------------------------------------------|
| /MDd      Yes        No             MSVCRTD.LIB, MSVCIRTD.LIB  |
------------------------------------------------------------------
 
Summary Table for CRT DLLs Used
---------------------------------------------------
| Import Library   DLLs Used        DLLs Used     |
| Linked With      (VC 5.0|6.0)         (VC 4.2)  |
|=================================================|
| MSVCRT.LIB       MSVCRT.DLL       MSVCRT.DLL    |
|-------------------------------------------------|
| MSVCRTD.LIB      MSVCRTD.DLL      MSVCRTD.DLL   |
|-------------------------------------------------|
| MSVCPRT.LIB      MSVCP5(5|6)0.DLL               |
|-------------------------------------------------|
| MSVCPRTD.LIB     MSVCP5(5|6)0D.DLL              |
|-------------------------------------------------|
| MSVCIRT.LIB      MSVCIRT.DLL      MSVCIRT.DLL   |
|-------------------------------------------------|
| MSVCIRTD.LIB     MSVCIRTD.DLL     MSVCIRTD.DLL  |
--------------------------------------------------- 
REFERENCES
For additional information, please see the following article in the Microsoft Knowledge Base: For additional information about , please see the following article(s) in the Microsoft Knowledge Base:
Q154419 Standard C++ Library Frequently Asked Questions
Additional query words: MSVCRT.DLL MSVCIRT.DLL MSVCPRT.LIB LIBCI.LIB LIBCIMT.LIB LIBCP.LIB LIBCPMT.LIB
================================================================
[MFC经常问到的问题]
Table 2. Static and Dynamic Libraries Included with Microsoft Visual C++ 4.2
| 
 Library types and related compiler switches  | 
 Basic C runtime 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)  | 
=======================================================================
[standard C++ Library经常问到的问题](注意:不是STL)
| 
 FAQ: Standard C++ Library Frequently Asked Questions  | 
Q154419
SUMMARY
This article presents a list of Frequently Asked Questions (FAQs) regarding the Standard C++ Libraries, and the answers to those questions. For additional information regarding the Standard C++ Libraries, please refer to the draft ANSII Standard Specification and the MSDN Library.
MORE INFORMATION
Standard C++ Libraries Frequently Asked Questions
Question 1
What does the Standard C++ Library contain? 
A. The Standard C++ Library provides an extensible framework and contains components for language support, diagnostics, general utilities, strings, locales, standard template library (containers, iterators, algorithms, numerics,) and input/output. 
The Standard C++ Library can be divided into the following categories: 
Standard Template Library (STL) components provide a C++ program with access to a subset of the most widely-used algorithms and data structures. STL headers can be grouped into three major organizing concepts: containers, algorithms, and iterators:
Containers are template classes that support common ways to organize data, such as <vector>, <list>, <deque>, <stack>, <queue>, <set>, and <map>.
Algorithms are template functions for performing common operations on sequences of objects, such as <functional>, <algorithm>, and <numeric>.
Iterators are the glue that pastes algorithms and containers together, such as <utility>, <iterator>, and <memory>.
Input Output includes components for forward declarations of iostreams (<iosfwd>), predefined iostreams objects (<iostream>), base iostreams classes (<ios>), stream buffering (<streambuf>), stream formatting and manipulators (<iosmanip>, <istream>, <ostream>), string streams (<sstream>), and file streams (<fstream>).
Other Standard C++ Headers include:
Language Support: components for common type definitions used throughout the library (<cstddef>), characteristics of the predefined types (<limits>, <cfloat>, <climits>), functions supporting start and termination of a C++ program (<cstdlib>), support for dynamic memory management (<new>), support for dynamic type identification (<typeinfo>), support for exception processing (<exception>), and other runtime support (<cstdarg>, <ctime>, <csetlmp>, <csignal>).
Diagnostics: components for reporting several kinds of exceptional conditions (<stdexcept>),documenting program assertions (<cassert>), and a global variable for error number codes (<cerrno>).
Strings: components for string classes (<string>), and null-terminated sequence utilities (<cctype>, <cwctype>, <cwchar>).
Localization: components that C++ programs may use to encapsulate cultural differences. The locale facility includes internationalization support for character classification and string collation, numeric, monetary, and date/time formatting and parsing, and message retrieval (<locale>, <clocale>).
Question 2
What is the difference between C-Runtime Library and Standard C++ Library? What libraries will the Runtime Library compiler options such as /ML, /MT, /MD, /MLd, /MTd, and /MDd include?
A. Prior to Visual C++ 4.2, the C-Runtime Library included: 
 
      |------------------------------------------------------------|
      | C-Runtime Library Types and    |    Standard C++           |
      | Related Compiler Switches      |       Library             |
      | -----------------------------------------------------------|
      | Single Threaded (ML)           |    LIBC.LIB               |
      | Multithreaded (MT)             |    LIBCMT.LIB             |
      | Multithreaded DLL version (MD) |    MSVCRT.LIB (Import     |
      |                                |    Library for            |
      |                                |    MSVCRT40.DLL)          |
      | Debug Single Threaded (MLd)    |    LIBCD.LIB              |
      | Debug Multithreaded (MTd)      |    LIBCMTD.LIB            |
      | Debug Multithreaded DLL (MDd)  |    MSVCRTD.LIB (Import    |
      |                                |    Library for            |
      |                                |    MSVCRT40D.DLL)         |
      |------------------------------------------------------------| 
Visual C++ 4.2 and later include the following Libraries in addition to the MFC libraries:
Basic C-Runtime Library.
Standard C++ Library.
Old iostream Library.
With Visual C++ 4.2 and later, the iostream support has been pulled out of the C-Runtime Library and exists as an independent entity. The following libraries are current:
 
      |--------------------------------|---------------------------|
      | Library Types and              |    Basic C Runtime        |
      | Related Compiler Switches      |        Library            |
      |--------------------------------|---------------------------|
      | Single-Threaded (ML)           |    LIBC.LIB               |
      | Multithreaded (MT)             |    LIBCMT.LIB             |
      | Multithreaded DLL version (MD) |    MSVCRT.LIB (Import     |
      |                                |    Library for            |
      |                                |    MSVCRT.DLL)            |
      | Debug Single-Threaded (MLd)    |    LIBCD.LIB              |
      | Debug Multithreaded (MTd)      |    LIBCMTD.LIB            |
      | Debug Multithreaded DLL (MDd)  |    MSVCRTD.LIB (Import    |
      |                                |    Library for            |
      |                                |    MSVCRTD.DLL)           |
      |------------------------------------------------------------|
 
      |--------------------------------|---------------------------|
      | Library Types and              |      Standard C++         |
      | Related Compiler Switches      |        Library            |
      |--------------------------------|---------------------------|
      | Single-Threaded (ML)           |    LIBCP.LIB              |
      | Multithreaded (MT)             |    LIBCPMT.LIB            |
      | Multithreaded DLL version (MD) |    MSVCPRT.LIB*(Also uses |
      |                                |             MSVCRT.DLL)   |
      | Debug Single-Threaded (MLd)    |    LIBCPD.LIB             |
      | Debug Multithreaded (MTd)      |    LIBCPMTD.LIB           |
      | Debug Multithreaded DLL (MDd)  |    MSVCPRTD.LIB* (Also    |
      |                                |        uses MSVCRTD.DLL)  |
      |------------------------------------------------------------| 
(* NOTE: MSVCPRT.LIB and MSVCPRTD.LIB are static libraries and do not have any DLLs directly related to them. These libraries are also dependent on MSVCRT.DLL and MSVCRTD.DLL, respectively. If you have any applications that use MSVCPRT.LIB or MSVCPRTD.LIB and you use the "Ignore Default Library" (/NOD or NODEFAULTLIB) option, be sure to link MSVCPRT.LIB (or MSVCPRTD.LIB) and MSVCRT.LIB (or MSVCRTD.LIB) with your application. Otherwise, you will get linker errors (LNK2001: unresolved externals in MSVCPRT.LIB or MSVCPRTD.LIB) when linking your application.)
 
      |--------------------------------|---------------------------|
      | Library Types and              |      Old iostream         |
      | Related Compiler Switches      |        Library            |
      |--------------------------------|---------------------------|
      | Single-Threaded (ML)           |    LIBCI.LIB              |
      | Multithreaded (MT)             |    LIBCIMT.LIB            |
      | Multithreaded DLL version (MD) |    MSVCIRT.LIB (Import    |
      |                                |    Library for            |
      |                                |    MSVCIRT.DLL)           |
      | Debug Single-Threaded (MLd)    |    LIBCID.LIB             |
      | Debug Multithreaded (MTd)      |    LIBCIMTD.LIB           |
      | Debug Multithreaded DLL (MDd)  |    MSVCIRTD.LIB (Import   |
      |                                |    Library for            |
      |                                |    MSVCIRTD.DLL)          |
      |------------------------------------------------------------| 
In Visual C++ 4.2 and later, there are certain default libraries that your program will link with. When you build a release version of your project in Visual C++ 4.2 and later, one of the basic C-Runtime Libraries (LIBC.LIB, LIBCMT.LIB, and MSVCRT.LIB) is linked by default, depending on the compiler option you choose (single-threaded <ML[d]>, multithreaded <MT[d]>, or DLL<ML[d]>). Depending on the headers you use in your code, a library from the Standard C++ Library or one from the Old iostream Library may also be linked.
For example, if you specify the /ML (single-thread version) compiler option, and include <iostream>, a Standard C++ Library Header, the libraries LIBC.LIB and LIBCP.LIB are linked with your application by default. If you specify the /ML (single-thread version) compiler option, and include <iostream.h>, an Old iostream Header, the libraries LIBC.LIB and LIBCI.LIB are linked with your application by default.
Headers determine whether the Standard C++ Libraries and old iostream Libraries will be linked. Compiler options (/ML[d], /MT[d], /MD[d]) determine which version of the libraries (single-threaded, multithreaded, or DLL) is to be linked by default.
NOTE: It may seem that headers without the ".h" extension are Standard C++ Headers and ones with the ".h" extension are C-Runtime Headers or Old iostream Headers. This is not true. As explained below, the files <useoldio.h> and <use_ansi.h> determine the libraries with which your application will link.
Actually, there are two header files, <useoldio.h> and <use_ansi.h>, that contain #pragmas. The #pragmas force either the Old iostream Library or the Standard C++ Library to be linked in by default.
The header file <useoldio.h> contains #pragma statements that force the Old iostream Library to be linked in. All Old iostream Headers include <useoldio.h>: If you include any Old iostream header in your application, the Old iostream Library will be linked by default.
 
      |-------------------------|
      |  Old iostream Headers   |
      |-------------------------|
      | FSTREAM.H  | IOMANIP.H  |
      | IOS.H      | IOSTREAM.H |
      | ISTREAM.H  | OSTREAM.H  |
      | STDIOSTR.H | STREAMB.H  |
      | STRSTREA.H |            |
      |-------------------------| 
The header file <use_ansi.h> contains #pragma statements that force the Standard C++ Library to be linked in. All Standard C++ headers include <use_ansi.h>: if you include any Standard C++ Header in your application, the Standard C++ Library will be linked by default.
 
      |-------------------------------------------------|
      |             Standard C++ Headers                |
      |-------------------------------------------------|
      | ALGORITHM | BITSET    | COMPLEX    | DEQUE      |
      | EXCEPTION | FSTREAM   | FUNCTIONAL | IOMANIP    |
      | IOS       | IOSFWD    | IOSTREAM   | ISTREAM    |
      | ITERATOR  | LIMITS    | LIST       | LOCALE     |
      | MAP       | MEMORY    | NUMERIC    | OSTREAM    |
      | QUEUE     | SET       | SSTREAM    | STACK      |
      | STDEXCEPT | STREAMBUF | STRING     | STRSTREAM  |
      | TYPEINFO  | UTILITY   | VALARRAY   | VECTOR     |
      |-------------------------------------------------| 
You cannot mix calls to the Old iostream Library and the new Standard C++ Library.
For more information on related issues, please see Issues Surrounding iostream and the Standard C++ Library in Visual C++ Books Online. Also see Compiler Error C2371. 
Question 3
Can I use existing static or dynamic link libraries, built with Visual C++ 4.0 or Visual C++ 4.1, with applications being developed using Visual C++ 4.2 and later?
A. If your application is not going to use the Standard C++ Library, you can use the existing libraries in your application as they exist.
If your application is going to use the Standard C++ Library, you need to consider the following issues: 
You will have to re-build your libraries using the Standard C++ Library.
If your library is iostream intensive, you will need to re-write some parts of your code before you can re-build the library using the Standard C++ Library.
For more information on this question, see Differences Between Old and New iostream Implementations in Visual C++ Books Online, Issues Surrounding iostream and Standard C++ Library in Visual C++ Books Online, Differences between C-Runtime Library and Standard C++ Library, and The Ignore Default Libraries option.
Question 4
I ported my application from Visual C++ 4.1 to Visual C++ 4.2 or 5.0. I do not want to use the Standard C++ Libraries. How do I retain the Old iostream functionality?
A. If you want to retain the Old iostream Library, include one or more of the Old iostream Header files in your code. Do not use the new Standard C++ Headers. You cannot mix calls to the Old iostream Library and the new Standard C++ Library. 
For more information, see Issues Surrounding iostream and the Standard C++ Library in Visual C++ Books Online, or Differences between C-Runtime Library and Standard C++ Library? 
Question 5
How do I make the Standard C++ Libraries the default libraries for my application?
A. If you want to make the Standard C++ Libraries the default, include one or more of the new Standard C++ headers. Remember, you cannot mix calls to the Old iostream and the new Standard C++ Library. Existing libraries (static or dynamic link) that use iostream functions will have to be rebuilt using Standard C++ Library iostream functions. 
For more information, see Issues Surrounding iostream and the Standard C++ Library in Visual C++ Books Online, or Differences between C Runtime Library and Standard C++ Library. 
Question 6
Do I still need to include STL in a separate namespace (for example, "std") in order to use it with MFC?
A. No. Previous name conflicts between MFC and STL have been resolved in Visual C++ 4.2 and later. 
The answer is yes if you are using Visual C++ 5.0. 
NOTE: Visual C++ 4.2 did not implement STL in the namespace "std" but 5.0 and later do. 
Question 7
I want to use Standard C++ Libraries in an MFC application. Will this cause any conflicts with the C-Runtime Libraries?
A. No. MFC does not use any C-Runtime functions that will conflict with the Standard C++ Libraries.
Question 8
I am getting compiler error C2371: 'identifier' redefinition; different basic types. What is causing this?
A. Mixing Standard C++ Headers and Old iostream Headers will cause this error, even if they are included in different source files. Following are the different headers:
 
      |-------------------------|
      |  Old iostream Headers   |
      |-------------------------|
      | FSTREAM.H  | IOMANIP.H  |
      | IOS.H      | IOSTREAM.H |
      | ISTREAM.H  | OSTREAM.H  |
      | STDIOSTR.H | STREAMB.H  |
      | STRSTREA.H |            |
      |-------------------------|
 
      |-------------------------------------------------|
      |             Standard C++ Headers                |
      |-------------------------------------------------|
      | ALGORITHM | BITSET    | COMPLEX    | DEQUE      |
      | EXCEPTION | FSTREAM   | FUNCTIONAL | IOMANIP    |
      | IOS       | IOSFWD    | IOSTREAM   | ISTREAM    |
      | ITERATOR  | LIMITS    | LIST       | LOCALE     |
      | MAP       | MEMORY    | NUMERIC    | OSTREAM    |
      | QUEUE     | SET       | SSTREAM    | STACK      |
      | STDEXCEPT | STREAMBUF | STRING     | STRSTREAM  |
      | TYPEINFO  | UTILITY   | VALARRAY   | VECTOR     |
      |-------------------------------------------------| 
Question 9
I have a project that was built with the "Ignore Default Libraries" Option (/NOD or /NODEFAULTLIB). With Visual C++ 4.2 or later, I am getting linker error LNK2001: unresolved external symbol 'symbol' : on all iostream function calls. What has changed?
A. The iostream functions have been removed from the C-Runtime Library. 
If you are using the Old iostream functions, you will need to add an additional library as follows: LIBCI.LIB (single-threaded <ML>), LIBCIMT.LIB (multithreaded <MT>), or MSVCIRT.LIB (multithreaded dll <MD>). 
If you are using the New iostream functions included with the Standard C++ Library, you will need to add an additional library as follows: LIBCP.LIB (single-threaded <ML>), LIBCPMT.LIB (multithreaded <MT>), or MSVCPRT.LIB (multithreaded dll <MD>). 
Do not mix different versions of the libraries. For example, if you are using the single-threaded version of the C-Runtime Library, you must also use the single-threaded version of the Old iostream Library or Standard C++ Library. 
You cannot mix calls to the Old iostream Library functions and the new Standard C++ Library iostream functions. 
For more information, see Issues Surrounding iostream and the Standard C++ Library in Visual C++ Books Online. Also see Compiler Error C2371. 
Question 10
I am getting compiler warnings C4786 and/or C4788. None of the symbols in my program is anywhere near 255 characters in length. What is causing this?
A. C4786/C4788 is issued when a symbol's name exceeds 255 characters in length. This often happens with templates, and especially STL components. 
Ignoring this warning is usually safe. Use a #pragma warning (disable: 4786,4788) to suppress the messages. 
For more information, see Visual C++ Books Online "Build Errors - Compiler Warning (level 1) C4786." 
Question 11
I am getting compiler warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX. What does that mean?
A. Programs that use the Standard C++ Library must be compiled with C++ exception handling enabled. C++ exception handling can be enabled by:
Selecting the "Enable exception handling" option, in the C++ Language Category of the C/C++ tab in the Project Settings dialog box.
- or - 
By using the /GX compiler switch.
Question 12
I am getting compiler error C2146, followed by C2065 and finally C2143, all pointing to the same line in my source. What does this mean? 
A. This sequence of errors can be caused by the following type of construct:
 
      vector<int, allocator<int>>iV; 
The problem is caused by the consecutive >> at the end of the declaration. The solution is to put a space between two characters, so the above construct becomes:
 
      vector<int, allocator<int> > iV; 
This is consistent with the proposed ANSII specification.
Question 13
NOTE: This question does not apply to Visual C++ 5.0 or later. 
I am getting compiler error C2976 : 'identifier' : too few template parameters, when instantiating STL containers. Why do the Standard Template Library containers of Visual C++ 4.2 require an extra parameter? What is that extra parameter? 
A. The C++ standard is an evolving piece of work that should provide the most complete and up-to-date implementation of the Standard C++ Library. However, due to certain limitations, some features of the Standard Template Library have been implemented differently. 
Several STL components use Default Template Arguments. The ANSII draft specification for the STL container classes (such as vector) specifies that the second template argument (the allocator) have a default value of "allocator" as follows: 
 
      template<class T, class Allocator = allocator> class vector; 
The pre-defined class allocator utilizes Member Templates. Visual C++ version 4.2 does not support the use of Member Templates. 
Because it is not possible to directly implement the class allocator, allocator has been implemented as a template class in the current implementation of the STL. The problem lies in attempting to use the templated allocator class as a default template argument. Consider the following: 
 
      template<class T, class Allocator = allocator<T> > class vector; 
Visual C++ 4.2 does not support this syntax. This made it necessary, in the case of STL containers, to remove the default template argument for the allocator. The definition of vector now becomes:
 
      template<class T, class Allocator> class vector; 
The effect of this change is that declaring a container will now require that you explicitly specify the allocator class as a template argument. The following declaration of an int vector illustrates:
 
      vector<int> myVector; 
This will cause the following compiler error:
Compiler error C2976 : 'vector' : too few template parameters
To correct the error, the declaration must be changed to:
 
      vector<int, allocator<int> > myVector; 
It is good programming practice to use typedef statements when instantiating template classes. Using a typedef has the following advantages:
If the definition of the class template changes, you can simply change the typedef statement and the rest of your program will work as is.
Template class instantiations tend to get long. Using typedef improves the readability of the code.
For example, if you have a class template such as the following:
 
      template <class A, class B, class C, class D>
      class Test
      {
      } ; 
you can instantiate a template class using the above class template as follows:
 
      Test<int, int, float, float> ifClass1 ; 
To instantiate in a different source file, you must use:
 
      Test<int, int, float, float> ifClass2 ; 
If the definition of the class template Test changes as follows:
 
      template <class A, class B, class C, class D, class E>
      class Test
      {
      } ; 
you will have to modify every instance in your source code to reflect the change. 
Using a typedef would have made the process easier because you would only need to change the typedef statement. Use a typedef: 
 
      template <class A, class B, class C, class D>
      class Test
      {
      } ;
 
      typedef Test<int, int, float, float > MYCLASS ;
 
      MYCLASS myObj1 ;
      MYCLASS myObj2 ; 
if the class template Test definition changes:
 
      template <class A, class B, class C, class D, class E>
      class Test
      {
      } ;
 
      typedef Test<int, int, float, float, char> MYCLASS ;
 
      MYCLASS myObj1 ;
      MYCLASS myObj2 ;    
Note that the only necessary change was to the one line containing the typedef. 
This technique of using typedefs will help insulate you from possible future changes to the STL. The vector of ints above, for example, becomes: 
 
      typedef vector<int, allocator<int> > INTVECTOR; 
If all instances of a vector of ints are declared as type INTVECTOR, you will only need to change the typedef if a future version of Visual C++ returns to using a default template argument of allocator. Typedefs used in conjunction with conditional compilation can also help those dealing with multiple platform situations using multiple versions of STL. For example, a program being compiled for both UNIX (using HP's STL) and NT (using Visual C++ 4.2's STL) might have the following definition of INTVECTOR:
 
      #ifdef _MSC_VER // VC++ STL
      typedef vector<int, allocator<int> > INTVECTOR;
      #else   // HP STL
      typedef vector<int> INTVECTOR;
      #endif 
Additional query words: STL STL.H allocator vector deque list map multimap set multiset queue stack priority_queue
====================================================================
C Run-Time Debug Libraries
The following table lists the debug versions of the C run-time library files, along with their associated compiler options and environment variables. For a list of the release versions of these libraries, see C Run-Time Libraries.
Prior to Visual C++ 4.2, the C run-time libraries contained the iostream library functions. In Visual C++ 4.2, the old iostream library functions were removed from LIBCD.LIB, LIBCMTD.LIB, and MSVCRTD.LIB. This change was made because the Standard C++ library was added to Visual C++, and it contains a new set of iostream libraries.
Two sets of iostream functions are now included in Visual C++. The old iostream functions now exist in their own libraries: LIBCID.LIB, LIBCIMTD.LIB, and MSVCIRTD.LIB. The new iostream functions, as well as many other new functions, exist in the Standard C++ libraries: LIBCPD.LIB, LIBCPMTD.LIB, and MSVCPRTD.LIB.
The Standard C++ library and the old iostream library are incompatible and only one of them can be linked with your project. See the Standard C++ Library Overview and Make the Old iostream Library the Default for details.
When you build a debug version of your project, one of the basic C run-time debug libraries (LIBCD.LIB, LIBCMTD.LIB, and MSVCRTD.LIB) is linked by default, depending on the compiler option you choose (single-threaded, multithreaded, or DLL). Depending on the headers you use in your code, a debug library from the Standard C++ libraries or one from the old iostream libraries may also be linked.
If you include a Standard C++ library header in your code, a Standard C++ library will be linked in automatically by Visual C++ at compile time. For example:
   #include <ios> 
If you include an old iostream library header, an old iostream library will be linked in automatically by Visual C++ at compile time. For example:
   #include <ios.h>
Note that headers from the Standard C++ library and the old iostream library cannot be mixed.
Headers determine whether a Standard C++ library, an old iostream library, or neither will be linked. Compiler options determine which of the libraries to be linked is the default (single-threaded, multithreaded, or DLL). When a specific library compiler option is defined, that library is considered to be the default and its environment variables are automatically defined.
| 
 C Run-Time Debug Library (without iostream)  | 
 Characteristics  | 
 Option  | 
 Defined  | |
| 
 LIBCD.LIB  | 
 Single-threaded, static link  | 
 /MLd  | 
 _DEBUG  | |
| 
 LIBCMTD.LIB  | 
 Multithreaded, static link  | 
 /MTd  | 
 _DEBUG, _MT  | |
| 
 MSVCRTD.LIB  | 
 Multithreaded, dynamic link   | 
 /MDd  | 
 _DEBUG, _MT, _DLL  | |
| 
 1 In place of the “x” in the DLL name, substitute the major version numeral of Visual C++ that you are using. For example, if you are using Visual C++ version 4, then the library name would be MSVCR40D.DLL.  | 
 
  | 
 
  | ||
| 
 Standard C++ Debug Library  | 
 Characteristics  | 
 Option  | 
 Defined  | 
| 
 LIBCPD.LIB  | 
 Single-threaded, static link  | 
 /MLd  | 
 _DEBUG  | 
| 
 LIBCPMTD.LIB  | 
 Multithreaded, static link  | 
 /MTd  | 
 _DEBUG, _MT  | 
| 
 MSVCPRTD.LIB  | 
 Multithreaded, dynamic link (import library for MSVCRTD.DLL)  | 
 /MDd  | 
 _DEBUG, _MT, _DLL  | 
| 
 iostream Debug Library  | 
 Characteristics  | 
 Option  | 
 Defined  | 
| 
 LIBCID.LIB  | 
 Single threaded, static link  | 
 /MLd  | 
 _DEBUG  | 
| 
 LIBCIMTD.LIB  | 
 Multithreaded, static link  | 
 /MTd  | 
 _DEBUG, _MT  | 
| 
 MSVCIRTD.LIB  | 
 Multithreaded, dynamic link (import library for MSVCIRTD.DLL)  | 
 /MDd  | 
 _DEBUG, _MT, _DLL  | 
The debug versions of the library functions differ from the release versions mainly in that debug information was included when they were compiled (using the /Z7 or /Zi compiler option), optimization was turned off, and source code is available. A few of the debug library functions also contain asserts that verify parameter validity.
Using one of these debug libraries is as simple as linking it to your application with the /DEBUG:FULL linker option set. You can then step directly into almost any run-time function call.
==============================================================
LIBCP000000.lib中的第5个字母应该表示的是英文的“performance(为00000量身设计的/部署)的意思” [个人猜测]
如:LIBCPMT.LIB (缺省的:只当你从C++->Code Generate中指定“运行时使用多线程时”)
if you choose Multithreaded in the Use run-time library drop-down list in the Code Generation category of the C/C++ tab in the Project Settings dialog box, and you have included a Standard C++ header file in your code, LIBCPMT.LIB becomes the default library.
                    
                
                
            
        
浙公网安备 33010602011771号