Compiler Command Syntax and Environment Variables


Compiler Command Syntax:

aCC [options] [files]

Description:

The aCC command (the driver) invokes the HP aC++ compiling system.

CAUTION: You must use the aCC command to link your HP aC++ programs and libraries. This ensures that all libraries and other files needed by the linker are available.

Example:

aCC prog.C

Compiles the source file prog.C and puts the executable code in the file a.out.

For More Information:


files on the aCC Command Line

files represents a list of one or more files containing source or object code to be compiled or linked.

Each file can be:

All other files are passed directly to the linker by the compiler. C++ source files can also reference C++ header files (.H files) using the #include preprocessor directive.

Unless you use the -o option to specify otherwise, all files that the aCC compiling system generates are put in the working directory, even if the source files came from other directories.

C++ Source Files

HP aC++ source files must be named with extensions beginning with either .c or .C, possibly followed by additional characters.

If you compile only, each C++ source file produces an object file with the same file name prefix as the source file and a .o file name suffix. However, if you compile and link a single source file into an executable program in one step, the .o file is automatically deleted.

CAUTION: It is recommended that your source files have extensions of .c or .C only, without additional characters. While file extensions other than .c or .C are permitted for portability from other systems, other endings may not be supported by HP tools and environments.

C++ Header Files

Typically, header files are referenced in C++ source files using the #include preprocessor directive.

Preprocessed C++ Source Files

Files with names ending in .i are assumed to be preprocessor output files.

Files ending in .i are processed the same as .c or .C files, except that the preprocessor is not run on the .i file before the file is compiled.

Use the -P or the -E compiler option to preprocess a C++ source file without compiling it.

Assembly Language Source Files

Files with names ending in .s are assumed to be assembly source files.

The compiler invokes the assembler through cc to produce .o files from these.

Use the -S option to compile a C++ source file to assembly code and put the assembly code into a .s file.

Object Files

Files with .o extensions are assumed to be relocatable object files that are to be included in the linking.

The compiler invokes the linker to link the object files and produce an executable file.

Use the -c option to compile a C++ source file into a .o file.

Library Files

Files ending with .a are assumed to be archive libraries. Files ending with .sl are assumed to be shared libraries.

Use the -c and +z options to create object files of position-independent code (PIC) and the -b option to create a shared library.

Use the -c option to create object files and the ar command to combine the object files into an archive library.


More Examples of the aCC Command

Compiling and Renaming the Output File

aCC -o prog prog.C
Compiles prog.C and puts the executable code in the file prog, rather than in the default file a.out.

Compiling and Debugging

aCC -g prog.C
Compiles prog.C and includes information allowing you to debug the program with the HP/DDE Debugger, dde.

Compiling Without Linking

aCC -c prog.C
Compiles prog.C and puts the object code in the file prog.o. Does not link the object file and does not create an executable file.

Linking Several Object Files

aCC file1.o file2.o file3.o

Links the listed object files and puts the executable code in the file a.out.

CAUTION: You must use the aCC command to link your HP aC++ programs and libraries. This ensures that all libraries and other files needed by the linker are available.

Compiling, Optimizing, and Getting Verbose Information

aCC -O -v prog.C
Compiles and optimizes prog.C, gives verbose progress reports, and creates an executable file a.out.

Compiling and Creating a Shared Library

aCC +z -c prog.C
aCC -b -o mylib.sl prog.o

The first line compiles prog.C, creates the object file prog.o, and puts the position-independent code (PIC) into the object file. The second line creates the shared library mylib.sl, and puts the executable code into the shared library.


Environment Variables


You can use the following environment variables with HP aC++:

CXXOPTS
Specify command line options automatically.
CCLIBDIR
Specify additional directories for the linker to search for libraries.
CCROOTDIR
Use this when compiler subprocesses are in alternate directories.
TMPDIR
Change the location of temporary files that the compiler creates.


The CXXOPTS Environment Variable

Syntax:

export CXXOPTS="options | options"   ksh notation
setenv CXXOPTS "options | options"   csh notation

Description:

Provides a convenient way to include frequently used command line options automatically. Options before the vertical bar (|) are placed before any command line options to aCC. Options after the vertical bar are placed after any command line options. Note that the vertical bar must be delimited by white space.

If you do not use the vertical bar, all options are placed before the command line parameters.

Just set the environment variable and the options you want are automatically included each time you execute the aCC command.

Usage:

For quick or temporary changes to your build environment, you might use CXXOPTS instead of editing your makefiles.

Example:

export CXXOPTS="-v | -lm"   ksh notation
setenv CXXOPTS "-v | -lm"   csh notation

Causes the -v and -l options to be passed to the aCC command each time you execute it.

When CXXOPTS is set as above, the following two commands are equivalent:

aCC -g prog.C
aCC -v -g prog.C -lm


The CCLIBDIR Environment Variable

Syntax:

export CCLIBDIR=directory   ksh notation
setenv CCLIBDIR directory   csh notation

directory is an HP-UX directory where you want HP aC++ to look for libraries.

Description:

Causes the aCC command to search for libraries in an alternate directory before searching in the default directory, /opt/aCC/lib.

Example:

export CCLIBDIR=/mnt/proj/lib

Specifies that HP aC++ search the directory /mnt/proj/lib for libraries, then search the directory /opt/aCC/lib.

When CCLIBDIR is set as above, the following two commands are equivalent:

aCC -L/mnt/proj/lib file.o
aCC file.o

See Also:

Use the -Ldirectory option to specify additional directories for the linker to search for libraries.

The CCROOTDIR Environment Variable

Syntax:

export CCROOTDIR=directory   ksh notation
setenv CCROOTDIR directory   csh notation

directory is an aCC root directory where you want the HP aC++ driver to look for subprocesses.

Description:

Causes aCC to invoke all subprocesses from an alternate aCC directory, rather than from their default directory. The default aCC root directory is /opt/aCC.

Example:

export CCROOTDIR=/mnt/CXX2.1

Specifies that HP aC++ search the directories under /mnt/CXX2.1 (/mnt/CXX2.1/bin and /mnt/CXX2.1/lbin) for subprocesses rather than their respective default directories.


The TMPDIR Environment Variable

Syntax:

export TMPDIR=directory   ksh notation
setenv TMPDIR directory   csh notation

directory is the name of an HP-UX directory where you want HP aC++ to put temporary files during compilation.

Description:

Allows you to change the location of temporary files created by the compiler. The default directory is /var/tmp.

Example:

export TMPDIR=/mnt/temp   ksh notation
setenv TMPDIR /mnt/temp   csh notation

Specifies that HP aC++ should put all temporary files in /mnt/temp.


Floating Installation


As of HP aC++ A.01.12 (for HP-UX 10.x) and HP aC++ A.03.10 (for HP-UX 11.x) and subsequent versions, more than one version of the HP aC++ compiler can be installed on one system at the same time. The floating installation feature allows you to install the compiler in any location. You can install as many compiler versions as required, depending on your system's resources.

By default, HP aC++ is installed under the /opt/aCC directory. In prior releases, the compiler driver (aCC) looked for related files in subdirectories of /opt/aCC. This prevented installation of more than one version of HP aC++ on the same system at the same time.

Note that only the files in /opt/aCC are affected by floating installation. No matter which HP aC++ driver you are using, the compiler still uses the libraries, linker, and other files located in /usr/lib and /usr/ccs.

Floating installation is designed to help facilitate inhouse development. Be aware that you must not ship libraries in non-standard places, since explicit run-time library specifications and linker options are required.

Note: You can use the __HP_aCC predefined macro to determine which version is being run.


CAUTION: Floating installation is not intended for use with the following:

Setting Up Floating Installation

You may want to install the most recent compiler version and keep the prior version on one system. If there are problems with the most recent version, it is easy to switch to the prior one. Following is an example of how to set up the floating installation feature for this purpose.

Assume that your system will have two versions of the compiler, both floating install enabled. In this case, A.03.10 is the prior version, and A.03.13 is the more recent version.

  1. Copy the prior version to another directory.
    cp -rp /opt/aCC /opt/aCC.03.10
    
  2. Use swinstall to install the new (in this case, A.03.13) version.

  3. To invoke the A.03.10 compiler with its absolute path:
    /opt/aCC.03.10/bin/aCC app.C
    
    Alternatively, you could change your PATH environment variable or set up an alias for the absolute path.

  4. To invoke the A.03.13 compiler:
    aCC app.C
    
The HP aC++ driver accesses subprocesses for the version you invoke.