| Compiler Command Syntax |
The aCC command (the driver) invokes the HP aC++ compiling system.
Syntactically, the aCC command is followed by
options
and files that need to be compiled.
aCC [options] [files]
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
This command compiles the source file prog.C and puts the executable code
in the file a.out.
|
| Files on the
aCC Command Line |
Files on the aCC command line can be one or more files containing
source or object code to be compiled or linked. These files can be:
- C++ source files (.C files)
- Preprocessed source files (.i files)
- Assembly language source files (.s files)
- Object files (.o files)
- Library files (.sl or .a files)
C++ source files (.C files)
HP aC++ source files must be named with extensions beginning with either
.c or .C, possibly followed by additional characters.
If you perform a 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 unless
-g +objdebug is used.
Note: It is recommended that your source files have extensions
of .c or .C 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.
Preprocessed source files (.i 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 (.s files)
Files with names ending in .s are assumed to be assembly source files.
The compiler runs the preprocessor over .s files and then invokes the
assembler directly to produce the .o files from them.
Use the -S option to compile a C++ source file to assembly code and put
the assembly code into a .s file. .s files produced by
the Itanium-based
compiler are not suitable as input to the assembler.
Object files (.o files)
Files with .o extensions are assumed to be relocatable
object files that are to be included when 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 (.so or .a files)
Files ending with .a are assumed to be archive libraries. Files ending
with .so 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.
|
| Examples of
the aCC Command |
|
Following are some more examlpes of the aCC command:
|
| Environment Variables |
You can use the following environment variables with HP aC++:
aCC_FULL_PATHNAMES
Environment Variable
Exporting the aCC_FULL_PATHNAMES variable causes the compiler to include
full path names for files in compiler messages. This feature is useful in debugging.
CXXOPTS and CCOPTS Environment Variables
CXXOPTS provides a convenient way to include frequently used
command line options automatically in HP aC++. CCOPTS
performs the same function for HP C.
Set the environment variable and the options you want are automatically
included each time you execute the aCC command.
Syntax:
For HP aC++:
export CXXOPTS="options | options" ksh/sh notation
setenv CXXOPTS "options | options" csh notation
For HP C:
export CCOPTS="options | options" ksh/sh notation
setenv CCOPTS "options | options" csh notation
Options before the vertical bar (|) are placed before 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.
Example:
export CXXOPTS="-v | -lm" ksh/sh notation
setenv CXXOPTS "-v | -lm" csh notation
The above command 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
CCLIBDIR Environment Variable
CCLIBDIR causes the aCC command to search for libraries in an
alternate directory before searching in the default directories.
Syntax:
export CCLIBDIR=directory ksh/sh notation
setenv CCLIBDIR directory csh notation
directory is an HP-UX directory where you want HP aC++ to look for libraries.
Example:
export CCLIBDIR=/mnt/proj/lib
In this example HP aC++ searches the directory /mnt/proj/lib for libraries
before searching 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
Note: Use the -Ldirectory option to specify additional directories
for the linker to search for libraries.
CCROOTDIR Environment Variable
The CCROOTDIR environment variable 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.
Syntax:
export CCROOTDIR=directory ksh/sh notation
setenv CCROOTDIR directory csh notation
directory is an aCC root directory where you want the HP aC++
driver to look for subprocesses.
Example:
export CCROOTDIR=/mnt/CXX2.1
In the above example, HP aC++ searches the directories under
/mnt/CXX2.1 (/mnt/CXX2.1/bin and /mnt/CXX2.1/lbin)
for subprocesses rather than their respective default directories.
System Wide Configuration
You can configure compiler options on a system-wide basis.
The compiler can read a configuration file
/var/aCC/share/aCC.conf(aC++), or
/var/ansic/share/cc.conf (Ansi C), if present.
In C-mode, the configuration file defaults to /var/ansic/share/cc.conf, unless overridden by the environment variable CC_CONFIG.
In C++ mode, the config file defaults to ,tt>/var/aCC/share/aCC.conf,/tt>,
unless overriden by the environment variable CXX_CONFIG
The options in the configuration file can be specified in the same
manner as that for CCOPTS and CXXOPTS, namely:
[options-list-1] [|[options -list-2]]
where options in options-list-1 are applied before the options in the command line, and the options in options-list-2 are applied after the options in the command line. Note that no configuration files are shipped
along with aC++, but can be installed by the system administrator, if required.
TMPDIR Environment Variable
The TMPDIR environment variable allows you to change the location
of temporary files created by the compiler. The default directory is
/var/tmp.
Syntax:
export TMPDIR=directory ksh/sh 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.
Example:
export TMPDIR=/mnt/temp ksh notation
setenv TMPDIR /mnt/temp csh notation
The above example specifies that HP aC++ should put all temporary files in /mnt/temp.
|
| Floating Installation |
|
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
for HP aC++ and /opt/ansic directory for HP C. In earlier
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 (and /opt/ansic) 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. For C use __HP_cc.
Floating installation is not intended for use with the following:
- CCROOTDIR environment variable
- -tc,name command line option
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.
- Copy the prior version to another directory.
cp -rp /opt/aCC /opt/aCC.03.10
- Use swinstall to install the new version (in this case, A.03.13).
- Invoke the A.03.10 compiler with its absolute path using the following command:
/opt/aCC.03.10/bin/aCC app.C
Alternatively, you can change your PATH environment variable or set up
an alias for the absolute path.
- To invoke the A.03.13 compiler, use the following command:
aCC app.C
The HP aC++ driver accesses subprocesses for the version you invoke.
If you want to floating install a newer compiler, use swinstall to install
the compiler to an alternate root:
- swinstall .... @ /opt/aCC.03.13
- Invoke the A.03.13 compiler with its absolute path:
/opt/aCC.03.13/opt/aCC/bin/aCC app.c
Alternatively, you can change your PATH environment variable or set up an alias for the absolute path.
|