JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.3: C++ User's Guide     Oracle Solaris Studio 12.3 Information Library
search filter icon
search icon

Document Information


Part I C++ Compiler

1.  The C++ Compiler

2.  Using the C++ Compiler

3.  Using the C++ Compiler Options

Part II Writing C++ Programs

4.  Language Extensions

5.  Program Organization

6.  Creating and Using Templates

7.  Compiling Templates

8.  Exception Handling

9.  Improving Program Performance

10.  Building Multithreaded Programs

Part III Libraries

11.  Using Libraries

11.1 C Libraries

11.2 Libraries Provided With the C++ Compiler

11.2.1 C++ Library Descriptions

11.2.2 Accessing the C++ Library Man Pages

11.2.3 Default C++ Libraries

11.3 Related Library Options

11.4 Using Class Libraries

11.4.1 iostream Library Note About Classic iostreams and Legacy RogueWave Tools

11.4.2 Linking C++ Libraries

11.5 Statically Linking Standard Libraries

11.6 Using Shared Libraries

11.7 Replacing the C++ Standard Library

11.7.1 What Can Be Replaced

11.7.2 What Cannot Be Replaced

11.7.3 Installing the Replacement Library

11.7.4 Using the Replacement Library

11.7.5 Standard Header Implementation Replacing Standard C++ Headers Replacing Standard C Headers

12.  Using the C++ Standard Library

13.  Using the Classic iostream Library

14.  Building Libraries

Part IV Appendixes

A.  C++ Compiler Options

B.  Pragmas



11.4 Using Class Libraries

Generally, two steps are involved in using a class library:

  1. Include the appropriate header in your source code.

  2. Link your program with the object library.

11.4.1 iostream Library

The C++ compiler provides two implementations of iostreams:

If you have existing C++ sources, your code might look like the following example, which uses classic iostreams.

// file
#include <iostream.h>

int main() {
    cout << "Hello, world!" << endl;
    return 0;

The following example uses standard iostreams.

// file
#include <iostream>

int main() {
    std::cout << "Hello, world!" << std::endl;
    return 0;

The following command compiles and links into an executable program called prog2. The program is compiled in standard mode. libCstd, which includes the standard iostream library, is linked by default.

example% CC -o prog2 Note About Classic iostreams and Legacy RogueWave Tools

The so-called “Classic” iostreams is the original 1986 version of iostreams, which was replaced in the C++ standard. It is selected through the -library=rwtools7,iostream option. No two implementations of “classic” iostreams are the same, so apart from being obsolete, code using it is not portable. Note that this library and option will be discontinued in future Oracle Solaris Studio releases.

The RW Tools.h++ toolset provided with legacy Sun Studio and with Oracle Studio dates from the 1990's and has not been significantly updated since. It's time and date classes have serious issues regarding daylight savings time that cannot be fixed. (The functionality of this toolset is currently available in the C++ Standard and in open source libraries like BOOST.) RW Tools.h++ is selected by the -library=rwtools7 or -library=rwtools7_std options and will be discontinued in future Oracle Solaris Studio releases.

11.4.2 Linking C++ Libraries

The following table shows the compiler options for linking the C++ libraries. See A.2.49 -library=l[,l...] for more information.

Table 11-2 Compiler Options for Linking C++ Libraries

Classic iostream
Tools.h++ version 7


Tools.h++ version 7 debug


Garbage collection
STLport version 4
STLport version 4 debug
Apache stdcxx version 4
Sun Performance Library