HP.com home

Compaq C++ for Linux Alpha documentation

Content starts here
Compaq C++  README
February 2002

This is the README for Version cxx- of the Compaq C++ compiler for Linux Alpha.

Compaq Computer Corporation
Houston, Texas

© 2002 Compaq Computer Corporation

COMPAQ, the Compaq logo, and Alpha, DEC, Ladebug, OpenVMS, and VMS are registered in the U.S. Patent and Trademark Office. Tru64 is a trademark of Compaq Information Technologies Group, L.P. in the United States and other countries. UNIX is a trademark of The Open Group in the United States and other countries. All other product names mentioned herein may be trademarks of their respective companies.

Compaq shall not be liable for technical or editorial errors or omissions contained herein. The information is provided "as is" without warranty of any kind and is subject to change without notice. The warranties for Compaq products are set forth in the express limited warranty statements accompanying such products. Nothing herein should be construed as constituting an additional warranty.

Confidential computer software. Valid license from Compaq required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license.

1 Introduction

cxx is the Compaq C++ compiler for Linux Alpha. It is a port of the same compiler that is available on the Compaq Tru64tm UNIX® and OpenVMS Alpha platforms. The compiler produces excellent optimized code for the Alpha architecture, particularly for floating-point intensive applications.

There are some specific limitations and differences relative to the C++ compiler for Tru64 UNIX, including:

  • No support for feedback-based optimization.
  • No support for precompiled headers.
  • No support for Tru64-based performance tools like cord , atom or om .
  • The wchar_t type on Linux is unsigned int ; on Tru64 UNIX it is signed .
  • The long double data type is the same as double (Tru64 UNIX Version 5.0 makes long double a 16-byte IEEE quad-precision type).
  • The -ieee command-line option on Linux Alpha has additional properties that are not present on Tru64 UNIX systems. See the cxx(1) reference page for more information.
  • Compiler-generated .s files cannot be assembled by the assembler.
  • The compiler and libraries are not multithread-safe.
  • There is no task library.
  • The order of static initialization is inverted. For more information, see Order of Static Object Initialization in Using Compaq C++ for Tru64 UNIX and Linux Alpha .

The C++ compiler accepts some gcc extensions, but is primarily a ISO standard C++ compiler. The following enhancements have been made for compatibility with the GNU C++ compiler:

  • #include_next
  • The __inline keyword is enabled and is equivalent to inline . On non-Linux platforms this keyword is available by specifing -std gnu .
  • The -std gnu option can provide additional compatibility. For details, see the cxx(1) reference page.


The Compaq C++ compiler is not link-compatible with the GNU C++ compiler. This means that object files or libraries produced with one compiler cannot be linked with object files or libraries produced with the other. The GCC documentation, "info gcc trouble Interoperation" states:
GNU C++ does not do name mangling in the same way as other C++ compilers. This means that object files compiled with one compiler cannot be used with another.

This effect is intentional, to protect you from more subtle problems. Compilers differ as to many internal details of C++ implementation, including: how class instances are laid out, how multiple inheritance is implemented, and how virtual function calls are handled. If the name encoding were made the same, your programs would link against libraries provided from other compilers--but the programs would then crash when run. Incompatible libraries are then detected at link time, rather than at run time.

2 Differences between Compaq C++ and the C++ International Standard

The following item, specified in the C++ International Standard, is not currently supported but will be supported in a future version:

  • The export keyword for templates (Standard §14, paragraph 6; Stroustrup §9.2.3)

3 Supported Linux Alpha Distributions

Compaq C++ has been tested primarily under the Red Hat 6.2 Linux distribution for Alpha. It should, however, work on all distributions with GNU libc 2.1.n and Linux kernel 2.2 or later.

4 Getting the Software

Compaq C++ is now shipped as part of the Compaq Professional Linux Developer's Software on the web at http://h18000.www1.hp.com/products/software/alpha-tools/ . This suite of software includes C, C++, Fortran, Java, the CPML and CXML Math Libraries, Ladebug, and VisualThreads.

For commercial pricing and ordering information, see the Purchasing Information page . If you qualify, you can get Compaq C++ through the Enthusiast and Education (formerly Technology Enthusiast) program. Please see the Enthusiast and Education page for license terms and download instructions.

4.1 Prerequisites

Compaq C++ requires the following GNU/Linux components:

  • The GNU compiler system
  • The GNU development tools (binutils)

The following are optional:

  • The GNU debugger (gdb)

When Compaq C++ was originally released, support for the Compaq C++ compiler was not included in the development tools provided by all current Linux distributions. Compaq provides replacement development tools for those distributions. Current Linux distributions should already include support for Compaq C++.

4.2 Installation Requirements

Compaq C++ requires the following components:

  • The libots Run-Time library
  • The Compaq Portable Math Libraries (CPML)
  • The Compaq C compiler

The following are optional:

  • The Compaq Ladebug debugger

The versioning for libots, CPML, and Ladebug is consistent across Compaq C, C++, and Fortran compiler products. If you have already installed these packages and the packages on the download page or the distribution compact disc are not newer, there is no need to install them again. The Ladebug debugger shipped with the initial releases of Compaq C and Fortran did not support C++.

For better performance of math library routines, you should link against the cpml library instead of libm . Specifying -lm on the command line causes the cxx driver to pass -lcpml -lm to the linker. The cpml library comes in two different packages, only one of which can be installed on a given system:

  • cpml_ev5-version.alpha.rpm
    This package has code that runs best on Alpha chips prior to the EV6 (21264) processor. The code also runs on EV6 machines, but the EV6 version of the package provides code that runs significantly faster on EV6 processors.
  • cpml_ev6-version.alpha.rpm
    This package provides a library that is highly tuned for the EV6 processor, but it will not run on earlier processors (it might produce "Illegal instruction" traps).

The Tru64 UNIX Ladebug debugger has been ported to Linux Alpha. Ladebug is the recommended debugger for Compaq compilers. The GNU debugger (gdb) does not support Compaq C++. Compaq provides a replacement version that has minimal support for Compaq C++. You need this version only if you plan to debug Compaq C++ programs from gdb.


If you encounter problems with the Ladebug debugger, try using the -gall option.

4.3 Installation Instructions

The installation is straightforward with rpm -i if this is the first time the package is being installed, or with rpm -U if the package is being upgraded. The libots package should be installed before either of the cpml packages - the nature of the dependency between them is not handled by rpm 's installation-order dependency checks. You can install the other packages in any order. If you have previously installed a pre-release version of the compiler with a different package name, you should erase that package (using rpm -e ) before installing the cxx package. If you are installing a Beta kit and RPM complains about the package being older, add -oldpackage to the command line.

For example, to install on an EV6 system running RedHat 6.1, on which you have not previously installed a Compaq compiler, begin by installing updated binutils (and optionally gdb), because RedHat 6.1 did not support the Compaq C++ Compiler:

rpm -U compaq_rh61_binutils- 
rpm -U compaq_rh61_gdb-4.18-6.alpha.rpm 

Then enter the following commands:

rpm -i libots-2.2.7-2.alpha.rpm 
rpm -i cpml_ev6-5.1.0-4.alpha.rpm 
rpm -i ladebug-4.0.65-19.alpha.rpm 
rpm -i ccc- 
rpm -i cxx- 

Packages other than libots contain documentation files that you can list by entering a command in the following format after the package is installed:

rpm -qd package-name

To list the files before the package is installed, enter a command in the following format:

rpm -qdp package-name

5 Invoking the Compiler

The command line for invoking the compiler and linker is mostly compatible with both the gcc compiler and the Tru64 UNIX compiler. Where possible, command-line options for gcc are translated to near-equivalents for the compiler. Options that do not have Tru64 UNIX equivalents are silently ignored by default. Overall, there is a reasonable probability that a makefile that works on Linux Alpha using the g++ compiler can be used to build the same application with the cxx compiler by changing only the compiler invocation command from g++ to cxx . This change causes cxx to compile .cxx and .cpp files and ccc to compile .c files.

5.1 Simple Optimization

Having successfully built your application with cxx , you might want to try making it run faster.

Specifying the -fast option at the end of your compiler options is a good first step. By default, the -fast option tells the compiler to generate the fastest code for the machine on which the compiler is running. If you compile on an advanced processor like EV6 (for example, a DS10 machine), the code might produce "Illegal instruction" traps if you try to run it on an older machine. If you want to try some quick tuning but want to make sure the result will run on any Alpha machine, specify -fast -arch generic . You might also want to try adding -O4 to enable optimizations that could further improve performance. Be aware however, that under some conditions, these optimizations could degrade performance.

The cxx(1) reference page and Using Compaq C++ for Tru64 UNIX and Linux Alpha contain more information about optimization controls and tuning. See the documentation section for the location and status of the documentation in this kit.

5.2 Using GNU Development Tools with Compaq C++

In binutils, some tools demangle by default; others require that you specify the --demangle option. To use the Compaq demangler, you must also specify the --style=compaq option. The --style option was added in binutils version 2.9.5 or later and has been ported to version 2.9.1 in the released kits.

Affected tools are: ld , objdump , gprof , nm , and addr2line .

To use the Compaq demangler in gdb, specify the command set demangle-style compaq .

6 Documentation

The following documentation is provided in HTML format on the installed system under the directory /usr/doc/cxx- .

The cxx(1) reference page is derived from the cxx(1) reference page for Tru64 UNIX. It has been edited significantly to reflect differences between Tru64 UNIX and Linux Alpha behaviors.

7 Redistributing Run-Time Libraries with Applications

Users with a valid license are permitted to redistribute the libots and cpml Run-Time library packages included in the product, as follows.

If the application is linked with the -non_shared option ( -static in gcc terms), or is linked against the archive library ( .a ) form of these libraries, no redistribution is necessary (although it is permitted).

If the application is linked -call_shared ( -dynamic in gcc terms) and depends on libots.so and/or libcpml.so , then it is necessary for you to provide these libraries along with your application. The libraries should be redistributed in the form of the original RPMs (or updated versions of them) as provided by Compaq, and the users of the application should be advised to install them on the systems that will run the application.

If you redistribute cpml_ev6 , you need to caution your users that it should only be installed on an EV6 or newer version of the Alpha processor. The cpml_ev5 package can be installed on any version of the Alpha processor, but will not provide maximum performance on EV6 or newer processors.

8 Known Problems and Restrictions for the Linux Alpha Operating System

This section describes known problems and restrictions for the Linux Alpha operating system.

8.1 Known Problems

Known problems are as follows:

  • Inputting a pointer to void argument using the standard iostreams insertion operator>>(void*&) does not work.

8.2 Restrictions

Restrictions are as follows;

  • On some Linux releases, the header file /use/include/wctype.h incorrectly defines wctrans_t as __const unsigned int * , while the Compaq C++ implementation expects __const int * . As a result, you might see an "incompatible parameter" error.
    This error is discretionary and can be disabled by specifying -msg_disable incompatibleprm on the command line or by enclosing your code within a #pragma, as shown in the following example:

    #include <wctype.h> 
    int main() { 
            wint_t w = L'a'; 
    #pragma message save 
    #pragma message disable incompatibleprm 
            towupper(w);  // This statement causes the error 
    #pragma message restore 
            return 0; 
  • On Linux, the linker command ld supports an option of the form -B<static/dynamic/symbolic> . This option conflicts with the Compaq C++ compiler -B option is not supported.
  • The Class Library iomanipulators lock() and unlock() are no-ops. In other words, you can use them, but they do nothing.
    Some undocumented Class Library iostream functions provided on Tru64 UNIX for backward compatibility only are not available on Linux Alpha; for example: streambuf::xsputn() and streambuf::xsgetn() . You should use the documented versions instead ( streabuf::sputn() and streambuf::sgetn() ).
    You cannot use the GNU library headers with Compaq C++ library executables, and you cannot use Compaq C++ headers with the GNU library executables, even if the names of the classes are the same.
    The Class Library, libcxx , is not distributed in shared form. You must use the archive version.
    Some of the Red Hat 5.2 locale files are bad. For example, trying to set locale to the ja_JP.EUC locale does not work. Even on Red Hat 6.0, you may get inconsistent results from Tru64 Unix. For example, the Hungarian thousands_sep() is a space on Tru64 Unix but a null character on Linux Alpha. The discrepancy is due to the differing locale information provided by the two operating systems.

9 Known Library Restrictions

The following are restrictions:

  • The Class Library task package is not supported on the Linux Alpha platform.
  • The Class and Standard Libraries are not multithread-safe.

10 Downloading Updates and Learning about Related Products

For information about downloading updates to Compaq C++, Compaq Ladebug, CPML, and related products for Linux Alpha systems, please see the following Web page:


For information about other third-party products for the Linux Alpha platform, please see the following Web page:


11 Suggestion/Problem Reporting

Premium support is available in per-incident "call packs" from HP Services in the US and some other countries. For more information see http://www.hp.com/wwsolutions/linux/services.html. Support phone numbers are available on the web at http://welcome.hp.com/country/us/en/contact_us.html

Free support is limited to bug reports that can be sent to . Send a complete but short example reproducing the problem, including the following:

  • Compiler and operating system versions
  • All necessary sources (such as INCLUDE files and module sources)
  • Data files
  • Commands used to compile, link and run the program
  • Expected results and incorrect results obtained

Please try to reduce the problem to as small a source as possible, because we may be unable to diagnose large applications.

We answer most quickly those problem reports that include a small but complete reproducible example, along with descriptions of the compile and link options used and the exact text of any diagnostic messages or other incorrect results. Reports that include only program fragments or involve very large applications generally take longer to diagnose.

Please note that this is not a "programming consulting service" and you should have clear evidence of a product problem before contacting us. If you need consulting services, please contact Compaq Services.

If your question is about how to use some aspect of the product, or how to program using Compaq C++, visit the newsgroup comp.os.linux.alpha, where you can post questions and share experiences with other Alpha Linux users.