Sun Java Solaris Communities My SDN Account Join SDN
 

Sun Studio C++ Libraries

THE RIGHT TOOLS
Make all the difference. Choose the best.
 Download Sun Studio today
Several libraries are shipped with the C++ compiler. Some of these libraries are available only in compatibility mode (-compat=4), some are available only in the standard mode (-compat=5), and some are available in both modes. The libgc and libdemangle libraries have a C interface and can be linked to an application in either mode.
 
This article discusses the differences between the two libraries, libCstd and libstlport, and explores the situations in which one library is preferred over the other.
 
libgc (C++ Garbage Collection)
This library is used in deployment mode or garbage collection mode. Simply linking with the libgc library automatically and permanently fixes a program's memory leaks. Refer to the C++ User's Guide for an example of how to link your program. When you link your program with the libgc library, you can program without calling free or delete while otherwise programming normally. The garbage collection library has a dependency on the dynamic load library so specify -lgc and -ldl when you link your program. Additional information can be found in the gcFixPrematureFrees(3) and gcInitialize(3) man pages.
 
This article discusses some of the runtime errors related to memory management and how you can use the garbage collection library, libgc to fix these errors.
 
libC
This is the library needed in compatibility mode (-compat=4). It contains the C++ runtime support as well as the classic iostreams.
 
libCstd
This is the C++ standard library. In particular, it includes iostreams. If you have existing sources that use the classic iostreams and you want to make use of the standard iostreams, you have to modify your sources to conform to the new interface. See the C++ Standard Library Reference online manual for details. This manual is available only with the installed product.
 
libcomplex
This library provides complex arithmetic in compatibility mode (-compat=4). In the standard mode, the complex arithmetic functionality is available in libCstd.
 
libSTLport (C++ Stdlibs)
The STLport is an implementation of the C++ standard library. You can use this library instead of the default libCstd by specifying the option -library=stlport4. However, you cannot use libstlport and libCstd in the same program. You must compile and link everything, including imported libraries, using one or the other exclusively.
 
The Sun Studio C++ compiler provides a C++ interface to the C++ interval arithmetic library. To use the C++ interval arithmetic features, add the #include <suninterval.h> header file to the code, and then compile the code using the -xia command-line option.
 

 
 
 
»  Send Comments

Let us know what you like and don't like about the Compilers and Tools hub. Send us feedback. But for support questions, see the support page.