📄 index.txt
字号:
libstdc++ Frequently Asked Questions The latest version of this document is always available at [1]http://gcc.gnu.org/onlinedocs/libstdc++/faq/. The main documentation page is at [2]http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html. To the [3]libstdc++-v3 homepage. _________________________________________________________________ Questions 1. [4]General Information 1. [5]What is libstdc++-v3? 2. [6]Why should I use libstdc++? 3. [7]Who's in charge of it? 4. [8]How do I get libstdc++? 5. [9]When is libstdc++ going to be finished? 6. [10]How do I contribute to the effort? 7. [11]What happened to libg++? I need that! 8. [12]What if I have more questions? 9. [13]What are the license terms for libstdc++-v3? 2. [14]Installation 1. [15]How do I install libstdc++-v3? 2. [16][removed] 3. [17]What is this CVS thing that you keep mentioning? 4. [18]How do I know if it works? 5. [19]This library is HUGE! And what's libsupc++? 3. [20]Platform-Specific Issues 1. [21]Can libstdc++-v3 be used with <my favorite compiler>? 2. [22][removed] 3. [23][removed] 4. [24]I can't use 'long long' on Solaris 5. [25]_XOPEN_SOURCE / _GNU_SOURCE / etc is always defined 6. [26]OS X ctype.h is broken! How can I hack it? 7. [27]Threading is broken on i386 8. [28]Recent GNU/Linux glibc required? 9. [29]Can't use wchar_t/wstring on FreeBSD 10. [30]MIPS atomic operations 4. [31]Known Bugs and Non-Bugs 1. [32]What works already? 2. [33]Bugs in gcc/g++ (not libstdc++-v3) 3. [34]Bugs in the C++ language/lib specification 4. [35]Things in libstdc++ that only look like bugs o [36]reopening a stream fails o [37]-Weffc++ complains too much o [38]"ambiguous overloads" after including an old-style header o [39]The g++-3 headers are not ours o [40]compilation errors from streambuf.h o [41]errors about *Concept and constraints in the STL... o [42]program crashes when using library code in a dynamically-loaded library o [43]"memory leaks" in containers 5. [44]Aw, that's easy to fix! 5. [45]Miscellaneous 1. [46]string::iterator is not char*; vector<T>::iterator is not T* 2. [47]What's next after libstdc++-v3? 3. [48]What about the STL from SGI? 4. [49]Extensions and Backward Compatibility 5. [50][removed] 6. [51]Is libstdc++-v3 thread-safe? 7. [52]How do I get a copy of the ISO C++ Standard? 8. [53]What's an ABI and why is it so messy? _________________________________________________________________ 1.0 General Information1.1 What is libstdc++-v3? The GNU Standard C++ Library v3 is an ongoing project to implement the ISO 14882 Standard C++ library as described in chapters 17 through 27 and annex D. As the library reaches stable plateaus, it is captured in a snapshot and released. The latest release is [54]the fourteenth snapshot but newer versions have been included in recent GCC releases. For those who want to see exactly how far the project has come, or just want the latest bleeding-edge code, the up-to-date source is available over anonymous CVS, and can even be browsed over the Web (see [55]1.4 below). The older libstdc++-v2 project is no longer maintained; the code has been completely replaced and rewritten. [56]If you are using V2, then you need to report bugs to your system vendor, not to the V3 list. A more formal description of the V3 goals can be found in the official [57]design document. _________________________________________________________________1.2 Why should I use libstdc++? The completion of the ISO C++ standardization gave the C++ community a powerful set of reuseable tools in the form of the C++ Standard Library. However, all existing C++ implementations are (as the Draft Standard used to say) "incomplet and incorrekt," and many suffer from limitations of the compilers that use them. The GNU C/C++/FORTRAN/<pick-a-language> compiler (gcc, g++, etc) is widely considered to be one of the leading compilers in the world. Its development has recently been taken over by the [58]GCC team. All of the rapid development and near-legendary [59]portability that are the hallmarks of an open-source project are being applied to libstdc++. That means that all of the Standard classes and functions (such as string, vector<>, iostreams, and algorithms) will be freely available and fully compliant. Programmers will no longer need to "roll their own" nor be worried about platform-specific incompatibilities. _________________________________________________________________1.3 Who's in charge of it? The libstdc++ project is contributed to by several developers all over the world, in the same way as GCC or Linux. Benjamin Kosnik, Gabriel Dos Reis, Phil Edwards, Ulrich Drepper, Loren James Rittle, and Paolo Carlini are the lead maintainers of the CVS archive. Development and discussion is held on the libstdc++ mailing list. Subscribing to the list, or searching the list archives, is open to everyone. You can read instructions for doing so on the [60]homepage. If you have questions, ideas, code, or are just curious, sign up! _________________________________________________________________1.4 How do I get libstdc++? The [61]homepage has instructions for retrieving the latest CVS sources, and for browsing the CVS sources over the web. Stable versions of libstdc++-v3 are included with releases of [62]the GCC compilers. The subset commonly known as the Standard Template Library (chapters 23 through 25, mostly) is adapted from the final release of the SGI STL. _________________________________________________________________1.5 When is libstdc++ going to be finished? Nathan Myers gave the best of all possible answers, responding to a Usenet article asking this question: Sooner, if you help. _________________________________________________________________1.6 How do I contribute to the effort? Here is [63]a page devoted to this topic. Subscribing to the mailing list (see above, or the homepage) is a very good idea if you have something to contribute, or if you have spare time and want to help. Contributions don't have to be in the form of source code; anybody who is willing to help write documentation, for example, or has found a bug in code that we all thought was working, is more than welcome! _________________________________________________________________1.7 What happened to libg++? I need that! The most recent libg++ README states that libg++ is no longer being actively maintained. It should not be used for new projects, and is only being kicked along to support older code. The libg++ was designed and created when there was no Standard to provide guidance. Classes like linked lists are now provided for by list<T> and do not need to be created by genclass. (For that matter, templates exist now and are well-supported, whereas genclass (mostly) predates them.) There are other classes in libg++ that are not specified in the ISO Standard (e.g., statistical analysis). While there are a lot of really useful things that are used by a lot of people (e.g., statistics :-), the Standards Committee couldn't include everything, and so a lot of those "obvious" classes didn't get included. Since libstdc++ is an implementation of the Standard Library, we have no plans at this time to include non-Standard utilities in the implementation, however handy they are. (The extensions provided in the SGI STL aren't maintained by us and don't get a lot of our attention, because they don't require a lot of our time.) It is entirely plausable that the "useful stuff" from libg++ might be extracted into an updated utilities library, but nobody has started such a project yet. (The [64]Boost site houses free C++ libraries that do varying things, and happened to be started by members of the Standards Committee. Certain "useful stuff" classes will probably migrate there.) For the bold and/or desperate, the [65]GCC extensions page describes where to find the last libg++ source. _________________________________________________________________1.8 What if I have more questions? If you have read the README and RELEASE-NOTES files, and your question remains unanswered, then just ask the mailing list. At present, you do not need to be subscribed to the list to send a message to it. More information is available on the homepage (including how to browse the list archives); to send to the list, use [66]libstdc++@gcc.gnu.org. If you have a question that you think should be included here, or if you have a question about a question/answer here, contact [67]Phil Edwards or [68]Gabriel Dos Reis. _________________________________________________________________1.9 What are the license terms for libstdc++-v3? See [69]our license description for these and related questions. _________________________________________________________________ 2.0 Installation2.1 How do I install libstdc++-v3? Complete instructions are not given here (this is a FAQ, not an installation document), but the tools required are few: * A 3.x release of GCC. Note that building GCC is much easier and more automated than building the GCC 2.[78] series was. If you are using GCC 2.95, you can still build earlier snapshots of libstdc++. * GNU Make is recommended, but should not be required. * The GNU Autotools are needed if you are messing with the configury or makefiles. The file [70]documentation.html provides a good overview of the steps necessary to build, install, and use the library. Instructions for configuring the library with new flags such as --enable-threads are there also, as well as patches and instructions for working with GCC 2.95. The top-level install.html and [71]RELEASE-NOTES files contain the exact build and installation instructions. You may wish to browse those files over CVSweb ahead of time to get a feel for what's required. RELEASE-NOTES is located in the ".../docs/17_intro/" directory of the distribution. _________________________________________________________________2.2 [removed] This question has become moot and has been removed. The stub is here to preserve numbering (and hence links/bookmarks). _________________________________________________________________2.3 What is this CVS thing that you keep mentioning? The Concurrent Versions System is one of several revision control packages. It was selected for GNU projects because it's free (speech), free (beer), and very high quality. The [72]CVS entry in the GNU software catalogue has a better description as well as a [73]link to the makers of CVS. The "anonymous client checkout" feature of CVS is similar to anonymous FTP in that it allows anyone to retrieve the latest libstdc++ sources. After the first of April, American users will have a "/pharmacy" command-line option... _________________________________________________________________2.4 How do I know if it works? libstdc++-v3 comes with its own testsuite. You do not need to actually install the library ("make install") to run the testsuite, but you do need DejaGNU, as described [74]here. To run the testsuite on the library after building it, use "make check" while in your build directory. To run the testsuite on the library after building and installing it, use "make check-install" instead. If you find bugs in the testsuite programs themselves, or if you think of a new test program that should be added to the suite, please write up your idea and send it to the list! _________________________________________________________________2.5 This library is HUGE! And what's libsupc++? Usually the size of libraries on disk isn't noticeable. When a link editor (or simply "linker") pulls things from a static archive library, only the necessary object files are copied into your executable, not the entire library. Unfortunately, even if you only need a single function or variable from an object file, the entire object file is extracted. (There's nothing unique to C++ or libstdc++-v3 about this; it's just common behavior, given here for background reasons.) Some of the object files which make up libstdc++.a are rather large. If you create a statically-linked executable with -static, those large object files are suddenly part of your executable. Historically the best way around this was to only place a very few functions (often only a single one) in each source/object file; then extracting a single function is the same as extracting a single .o file. For libstdc++-v3 this is only possible to a certain extent; the object files in question contain template classes and template functions, pre-instantiated, and splitting those up causes severe maintenance headaches. It's not a bug, and it's not really a problem. Nevertheless, some people don't like it, so here are two pseudo-solutions: If the only functions from libstdc++.a which you need are language support functions (those listed in [75]clause 18 of the standard, e.g., new and delete), then try linking against libsupc++.a (usually specifying -lsupc++ when calling g++ for the final link step will do it). This library contains only those support routines, one per object file. But if you are using anything from the rest of the library, such as IOStreams or vectors, then you'll still need pieces from libstdc++.a. The second method is one we hope to incorporate into the library build process. Some platforms can place each function and variable into its own section in a .o file. The GNU linker can then perform garbage collection on unused sections; this reduces the situation to only copying needed functions into the executable, as before, but all happens automatically. Unfortunately the garbage collection in GNU ld is buggy; sections (corresponding to functions and variables) which are used are mistakenly removed, leading to horrible crashes when your executable starts up. For the time being, this feature is not used when building the library. _________________________________________________________________ 3.0 Platform-Specific Issues3.1 Can libstdc++-v3 be used with <my favorite compiler>? Probably not. Yet. Because GCC advances so rapidly, development and testing of libstdc++ is being done almost entirely under that compiler. If you are curious about whether other, lesser compilers (*grin*) support libstdc++, you are more than welcome to try. Configuring and building the library (see above) will still require certain tools, however. Also keep in mind that building libstdc++ does not imply that your compiler will be able to use all of the features found in the C++ Standard Library. Since the goal of ISO Standardization is for all C++ implementations
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -