Choose from the following topics for
information about the libraries provided with HP aC++ as well as
how you can create and use your own libraries.
For additional background, refer to the
HP-UX Online Linker and Libraries User's Guide
which is frequently referenced in these sections.
Migration
See Also
In addition to standard HP-UX system libraries,
HP aC++
provides the following C++ libraries.
Standards Based Libraries
HP C++ (cfront) Compatibility Libraries
NOTE:
HP aC++ provides the following libraries whose functionality is also
provided with HP C++ (cfront).
These libraries are not standards based.
See Also:
The International Standards Organization (ISO) and the American National
Standards Institute (ANSI) have completed the process of standardizing
the C++ programming language. A major result of this standardization
process is the Standard C++ Library, a large and comprehensive
collection of classes and functions. Choose from the following for more
details.
HP aC++ provides the Rogue Wave
implementation of the ANSI/ISO Standard C++ Library. This implementation
includes the following features:
- A subset of data structures and algorithms, updated from the
original library developed at Hewlett Packard by Alex Stepanov and
Meng Lee and known as the C++ Standard Template Library (STL).
NOTE:
The public domain C++ Standard Template Library is not supported by this Standard C++ Library.
For an introduction, see the following topics:
- A templatized
string class
- A templatized class for representing complex numbers
- A uniform framework for describing the execution environment,
through the use of a template class named
numeric_limits
and specializations for each fundamental data type
- Memory management features
- Language support features
- Exception handling features
For More Information
A major portion of the Standard C++ Library is comprised of a collection of
class definitions for standard data structures and a collection of algorithms
commonly used to manipulate such structures. This part of the library was
derived from the Standard Template Library or STL. The organization
and design of this part of the library differs in almost all respects
from the design of
most other C++ class libraries, because it avoids
encapsulation and uses almost no inheritance.
An emphasis on encapsulation is a key hallmark of object-oriented programming.
The emphasis on combining data and functionality into an object is a
powerful organization principle in software development; indeed it is the
primary organizational technique. Through the proper use of encapsulation,
even exceedingly complex software systems can be divided into manageable units
and assigned to various members of a team of programmers for development.
Inheritance is a powerful technique for permitting code sharing and software
reuse, but it is most applicable when two or more classes share a common set
of basic features. For example, in a graphical user interface, two types of
windows may inherit from a common base window class, and the
individual subclasses will provide any required unique features. In another
use of inheritance, object-oriented container classes may ensure common
behavior and support code reuse by inheriting from a more general class,
and factoring out common member functions.
The designers of the STL decided against using an entirely object-oriented
approach, and separated the tasks to be performed using common data
structures from the representation of the structures themselves.
The STL was designed as a collection of algorithms and,
separate from these, a collection of data structures that could be manipulated
using the algorithms.
The portion of the Standard C++ Library derived from the STL was purposely designed
with an architecture that is not object-oriented. This design
has both advantages and disadvantages. Some of them are mentioned below.
Smaller Source Code
There are approximately fifty different algorithms and
about a dozen major data structures. This separation has the
effect of reducing the size of source code, and decreasing some of the
risk that similar activities will have dissimilar interfaces. Were
it not for this separation, for example, each of the algorithms would
have to be re-implemented in each of the different data structures,
requiring several hundred more member functions than are found in the
present scheme.
Flexibility
One advantage of the separation of algorithms from data structures is
that such algorithms can be used with conventional C++ pointers and
arrays. Because C++ arrays are not objects, algorithms encapsulated
within a class hierarchy seldom have this ability.
Efficiency
The STL in particular, and the Standard C++ Library in general,
provide a low-level approach to developing C++ applications.
This low-level approach can be useful when specific
programs require an emphasis on efficient coding and speed of execution.
Iterators: Mismatches and Invalidations
The Standard C++ Library data structures use pointer-like objects
called iterators to describe the contents of a
container. Given the library's architecture,
it is not possible to verify that these iterator elements are matched,
that is, that they are derived from the same container. Using (either
intentionally or by accident) a beginning iterator from one container
with an ending iterator from another is a recipe for certain disaster.
It is very important to know that iterators can become invalidated as
a result of a subsequent insertion or deletion from the underlying
container class. This invalidation is not checked, and use of an
invalid iterator can produce unexpected results.
Familiarity with the Standard C++ Library will help reduce the number
of errors related to iterators.
Templates: Errors and "Code Bloat"
The flexibility and power of templatized algorithms is, with most
compilers, purchased at a loss of precision in diagnostics. Errors in
the parameter lists to generic algorithms will sometimes be manifest
only as obscure compiler errors for internal functions that are
defined many levels deep in template expansions. Again, familiarity
with the algorithms and their requirements is a key to successful use
of the standard library.
Heavy reliance on templates can cause programs
to grow larger than expected. You can minimize this problem by
learning to recognize the cost of instantiating a particular template
class, and by making appropriate design decisions. Be aware that as
compilers become more and more fluent in templates, this will become
less of a problem.
Multithreading Problems
The Standard C++ Library must be used carefully in a multithreaded
environment. Iterators, because they exist independently of the
containers they operate on, cannot be safely passed between threads.
Since iterators can be used to modify a non const container, there is
no way to protect such a container if it spawns iterators in multiple
threads. Use thread-safe wrappers, such as those provided by
Tools.h++ Library,
if you need to access a container from multiple threads.
Within a few years the Standard C++ Library will be the standard set
of classes and libraries delivered with all ANSI-conforming C++
compilers. Although the design of a large portion of the Standard C++ Library
is in many ways not object-oriented, C++ itself
excels as a language for manipulating objects. How
do you integrate the library's non-object-oriented
architecture with the language's strengths for manipulating objects?
The key is to use the right tool for each task. Object-oriented
design methods and programming techniques are almost without peer as
guideposts in the development of large complex software. For the
large majority of programming tasks, object-oriented techniques will
remain the preferred approach. Products such as Rogue Wave's
Tools.h++ Library which encapsulates the Standard C++ Library with a
familiar object-oriented interface, can provide you with the power
and the advantages of object-orientation.
Use Standard C++ Library components directly when you need flexibility
or highly efficient code. Use the more traditional approaches to
object-oriented design, such as encapsulation and inheritance, when
you need to model larger problem domains and knit all the pieces into
a full solution. When you need to devise an architecture for your
application, always consider the use of encapsulation and inheritance
to compartmentalize the problem. But if you discover that you need an
efficient data structure or algorithm for a compact problem
(the kind of problem that often
resolves to a single class), look to the Standard C++ Library. The
library excels in the creation of reusable classes, where
low-level constructs are needed, while traditional OOP techniques
really shine when those classes are combined to solve a larger
problem.
In the future, most libraries will use the Standard C++ Library as
their foundation. By using the Standard C++ Library, either directly
or through an encapsulation such as
Tools.h++ Library, you help insure
interoperability. This is especially important in large projects that
may rely on communication between several libraries. A good rule of
thumb is to use the highest encapsulation level available to you, but
make sure that the Standard C++ Library is available as the base for
interlibrary communication and operation.
The C++ language supports a wide range of programming approaches
because the problems we need to solve require that range. The
language, and now the Standard C++ Library that supports it, are
designed to give you the flexibility to approach each unique problem from
the best possible angle. The Standard C++ Library, when combined with
more traditional OOP techniques, puts a very flexible tool into the
hands of anyone building a collection of C++ classes, whether those
classes are intended to stand alone as a library or are tailored to a
specific task.
Select from the following categories to see further explanation from the
Rogue Wave Software Standard C++ Library 1.2.1 Class Reference.
Corresonding header file(s) are noted at the beginning of each category.
Note that system man pages are also available.
NOTE:
If you are accessing this guide from the World Wide Web URL,
http://docs.hp.com, rather than from a system on which HP aC++ is installed,
Rogue Wave documentation is not available.
The following links will not succeed.
Generic Algorithms--
for performing various operations on containers and
sequences:
#include
-
adjacent_find--
find the first adjacent pair of elements in a sequence that are equivalent
-
binary_search--
algorithm to perform a binary search on ordered containers
-
copy--
algorithm to copy values from one specified range to another; use to copy
values from one container to another, or to copy values from one location in
a container to another location in the same container
-
copy_backward--
algorithm to copy elements in one specified range to another,
starting from the end of the sequence and progressing to the front
-
count--
count the number of elements in a container that satisfy a given value
-
count_if--
count the number of elements in a container that satisfy a given predicate
-
equal--
compares two ranges for equality
-
equal_range--
find the largest subrange in a collection into which a given value can be
inserted without violating the ordering of the collection
-
fill--
initialize a range with a given value
-
fill_n--
assign a value to the elements in a sequence
-
find--
find an occurence of value in a sequence
-
find_end--
find a subsequence of equal values in a sequence
-
find_first_of--
find the first occurrence of any value from one sequence in another sequence
-
find_if--
in a sequence, find an occurrence of a value that satisfies a specifed
predicate
-
for_each--
apply a function to each element in a range
-
generate--
initialize a container with values produced by a value-generator class
-
generate_n--
initialize a container with values produced by a value-generator class
-
includes--
compare two sorted sequences and returns true if every element in one range
is contained in the other
-
inplace_merge --
merge two sorted sequences into one
-
iter_swap--
exchange values pointed at in two locations
-
lexicographical_compare--
compares two ranges lexicographically
-
lower_bound--
determine the first valid position for an element in a sorted container
-
make_heap--
creates a heap
-
max--
find and return the maximum of a pair of values
-
max_element--
find the maximum value in a range
-
merge--
merge two sorted sequences into a third sequence
-
min--
find and return the minimum of a pair of values
-
min_element--
find the minimum value in a range
-
mismatch--
compare elements from two sequences and return the first two elements that
don't match
-
next_permutation--
generate successive permutations of a sequence based on an ordering function
-
nth_element--
rearrange a collection so that all elements lower in sorted order than the
nth element come before it and all
elements higher in sorter order than the nth element come after it
-
partial_sort--
templated algorithm for sorting collections of entities
-
partial_sort_copy--
templated algorithm for sorting collections of entities
-
partition--
place all of the entities that satisfy the given predicate before all
of the entities that do not
-
pop_heap--
move the largest element off the heap
-
prev_permutation--
generate successive permutations of a sequence based on an ordering function
-
push_heap--
place a new element into the heap
-
random_shuffle --
randomly shuffle elements of a collection
-
remove--
move desired elements to the front of a container, and return an iterator
that describes where the sequence of desired elements ends
-
remove_copy--
similar to
remove
-
remove_copy_if--
similar to
remove
-
remove_if--
similar to
remove
-
replace--
substitute elements stored in a collection with new values
-
replace_copy--
similar to
replace
-
replace_copy_if--
similar to
replace
-
replace_if--
similar to
replace
-
reverse--
reverse the order of elements in a collection
-
reverse_copy--
reverse the order of elements in a collection while copying them to a
new collecton
-
rotate--
left rotates the order of items in a collection, placing the first item at
the end, second item first, etc., until the
item pointed to by a specified iterator is the first item in the collection
-
rotate_copy--
rotate elements as in
rotate, but instead of swapping elements
within the same sequence, copies the result of the rotation to a container
specified by result
-
search--
find a subsequence within a sequence of values that is element-wise equal
to the values in an indicated range
-
search_n--
similar to
search but searches for a given number of occurrences
-
set_difference--
construct a sorted difference that includes copies of the elements
present in one range but not in another, return the end of the constructed
range
-
set_intersection--
construct a sorted intersection of elements from two ranges, return the
end of the constructed range
-
set_symmetric_difference --
construct a sorted symmetric difference of the elements from two ranges,
include copies of the elements present in only one of the ranges
-
set_union--
construct a sorted union of the elements from two ranges, return
the end of the constructed range
-
sort--
templated algorithm for sorting collections of entities
-
sort_heap--
convert a heap into a sorted collection
-
stable_partition--
place all entities that satisfy the given predicate before all entities
that do not, while maintaining the relative order of elements in each group
-
stable_sort--
templated algorithm for sorting collections of entities
-
swap--
exchange values
-
swap_ranges--
exchange a range of values in one location with those in another
-
transform--
apply an operation to a range of values in a collection and stores the result
-
unique--
remove consecutive duplicates from a range of values and place the
resulting unique values into the result, overwriting the existin elements
-
unique_copy--
remove consecutive duplicates from a range of values and place the
resulting unique values into the resulting OutputIterator
-
upper_bound--
determines the last valid position for a value in a sorted container
The Standard C++ Library allocator interface encapsulates the types and functions needed to
manage the storage of data in a generic way. The interface wraps the
mechanism for managing data storage and separates this mechanism from the
classes and functions used to maintain associations between data elements.
This eliminates the need to rewrite containers and algorithms to suit
different storage mechanisms. You can encapsulate all the storage
mechanism details in an allocator, then provide that allocator to an existing
container when appropriate.
The Standard C++ Library provides a default
allocator
class that implements this interface using the standard new and
delete operators for all storage management.
Operations used to create and manipulate complex numbers.
#include
-
complex--
a template class used to create objects for representing and manipulating
complex numbers
Collection classes are often described as
Containers.
A container stores a
collection of other objects and provides certain basic functionality that
supports the use of generic algorithms.
Containers come in two basic flavors:
sequences and associative_containers.
They are further distinguished by the type of iterator they support.
#include
#include
#include
#include
-
bitset--
random access to a set of binary values; operations can be performed using
logical bit-wise operators, no iterators for accessing elements
-
deque --
random access, insertion at front or back
-
list--
insertion and removal throughout
-
map --
access to values via keys, insertion and removal
-
multimap--
map permitting duplicate keys
-
multiset--
set with repeated copies
-
priority_queue--
access and removal of largest value
-
queue--
insertion at back, removal from front
-
set--
elements maintained in order, test for inclusion, insertion, and removal
-
stack--
insertion and removal only from top
-
vector--
random access to elements, insertions at end
Allocation Policies for Containers
For -AP Standard Library
The inline template function __rw_allocation_size can
be explicitly specialized to return the number of units for each
types use in any container (see memory).
template <>
inline size_t __rw-allocation_size(bar*,size_t) {
return 1;
}
This would initially allocate 1 unit when dealing with
containers of bar type. Alternately if RWSTD_STRICT_ANSI
is not defined, then container member functions allocation_size can be
used to directly set buffer_size, the number of units to allocate.
For -AA Standard Library
The namespace scope function template __rw can be explicitly
specialized to return the current size in elements of any container.
template <>
inline size_t __rw_new_capacity (size_t __size, const _Container*)
The parameters passed in are the current size in elements and the
container's pointer. The default behavior results in an amortized
constant time algorithm that dramatically increases rapidity while
retaining a regard for space efficiency.
The defaults have been tuned with speed vs. space optimization of
container performance with regard to allocation of memory.
The ratio parameter must be above one for an amortized constant time
algorithm. Lowering the ratio will lower rapidity and improve space
efficiency. This effect will be most noticable when working with
containers of few elements (few being less than 32).
#include
-
exception--
base class to support logic and runtime errors
Used to build new function objects out of existing function objects.
#include
-
not1--
use to reverse the sense of a unary predicate function object
-
not2--
use to reverse the sense of a binary predicate function object
-
ptr_fun--
adapt a pointer to a function to work where a function is called for
Objects with an operator() defined.
Function objects are used in place of pointers to functions as arguments
to templated algorithms.
#include
-
binary_function--
base class for creating binary function objects
-
binary_negate--
returns the complement of the result of its binary predicate
-
bind1st and binder1st--
templatized utilities to bind a value to the first argument of a binary
function object
-
bind2nd and binder2nd--
templatized utilities to bind a value to the second argument of a
binary function object
-
divides--
returns the result of dividing its first argument by its second
-
equal_to--
returns true if its first argument equals its second
-
greater--
returns true if its first argument is greater than its second
-
greater_equal--
returns true if its first argument is greater than or equal to its second
-
less--
returns true if its first argument is less than its second
-
less_equal--
returns true if its first argument is less than or equal to its
second
-
logical_and--
returns true if both of its arguments are true
-
logical_not--
returns true if its argument is false
-
logical_or--
returns true if either of its arguments is true
-
minus--
returns the result of subtracting its second argument from its first
-
modulus--
returns the remainder obtained by dividing the first argument by the second
argument
-
negate--
returns the negation of its argument
-
not_equal_to--
returns true if its first argument is not equal to its second
-
plus--
returns the result of adding its first and second arguments
-
pointer_to_binary_function--
adapts a pointer to a binary function to work where a binary_function
function object is called for
-
pointer_to_unary_function--
adapts a pointer to a function to work where a unary_function function
object is called for
-
times--
returns the result of multiplying its first and second arguments
-
unary_function--
base class for creating unary function objects
-
unary_negate--
function object class that returns the complement of the result of its unary
predicate
#include
-
accumulate--
accumulates all elements within a range into a single value
-
adjacent_difference--
outputs a sequence of the differences between each adjacent pair of elements
in a range
-
inner_product--
computes the inner product A X B of two ranges A and B
-
partial_sum--
calculates successive partial sums of a range of values
Insert Iterators
are adaptors that allow an iterator to insert into a container rather than
overwrite elements in the container.
#include
-
back_insert_iterator--
class to insert items at the end of a collection
-
back_inserter--
function to create an instance of a back_insert_iterator for a
particular collection type
-
front_insert_iterator--
class to insert items at the beginning of a collection
-
front_inserter--
function to create an instance of a front_insert_iterator for a particular
collection type
-
insert_iterator--
class to insert items into a specified location of a collection
-
inserter--
function to create an instance of an insert_iterator given a particular
collection type and iterator
#include
-
advance--
move an iterator forward or backward (if available) by a specified distance
-
distance--
compute the distance between two iterators
-
distance_type--
determine the type of distance used by an iterator
-
iterator_category--
determine the category to which an iterator belongs
-
value_type--
determine the type of value to which an iterator points
Iterators
are pointer generalizations for traversal and modification of collections.
#include
#include
-
get_temporary_buffer--
pointer based primitive to reserve the largest possible buffer
that is less than or equal to the size requested
-
return_temporary_buffer--
pointer based primitive to return to available mamory a buffer previously
allocated via get_temporary_buffer
#include
-
auto_ptr --
a simple, smart pointer class
-
raw_storage_iterator--
enable iterator-based algorithms to store results into uninitialized memory
-
uninitialized_copy--
algorithm that uses the
construct primitive to copy values from
one range to another location
-
uninitialized_fill--
algorithm that uses the
construct primitive to set values in a collection
-
uninitialized_fill_n--
algorithm that uses the
construct primitive to set values in a collection
#include
-
numeric_limits--
a class for representing information about scalar types
#include
Stream iterators allow generic algorithms to be used directly on streams.
-
istream_iterator--
stream iterator provides iterator capabilities for istreams
-
ostream_iterator--
stream iterator to provide iterator capabilities for ostreams and istreams
#include
-
basic_string--
templated class for handling sequences of character-like entities
-
string--
a specialization of the
basic_string class
-
string_char_traits --
a traits class providing types and operations to the basic_string container
-
wstring--
a specializatio of the
basic_string class
#include
-
pair--
class that provides a template for encapsulating pairs of values that may be of different types
#include
- operator!=
- operator>
- operator<=
- operator>=
The Tools.h++ Library is a foundation class library built on the Standard C++ Library.
Use its object oriented capabilities
to simplify coding and facilitate code reuseablility.
Choose from the following for more information:
The HP aC++ run-time support library is provided as a shared library,
/usr/lib/libCsup.sl and as an archive library, /usr/lib/libCsup.a.
The library supports the following functionality:
- Exception Handling
- Memory Management (operators
new and delete)
- Start and termination of a C++ program
- Run-time type identification (type_info)
- static object constructors and desctructors
For More Information
NOTE:
At this release of HP aC++, the standards based iostream capabilities
of the Standard C++ Library are still evolving. As a result,
an HP C++ (cfront) compatible IOStream library is provided.
For More Information
You can compile and link any C++ modules to one or more libraries.
HP aC++ automatically links the following with a
C++ executable. Note that when you specify the
-b
option to create a shared library, these defaults do not apply.
-
/usr/lib/hpux##/libCsup.so (the HP aC++ run-time support library)
-
/usr/lib/hpux##/libstd.so (standard C++ library)
-
/usr/lib/hpux##/libstd_v2.so (standard C++ library -AA)
-
/usr/lib/hpux##/libstream.so(iostream library)
-
/usr/lib/hpux##/libc.so (the HP-UX system library)
-
/usr/lib/hpux##/libdld.so (routines for managing shared libraries)
-
/usr/lib/hpux##/libm.so (math library)
-
/usr/lib/hpux##/libunwind.so (routines for unwinding)
For ## substitute either 32 or 64 as appropriate.
Linking with Shared or Archive Libraries
If you want archive libraries instead of shared libraries, use the
-a,archive linker option.
NOTE:
To maintain compatibility on future releases, archive and shared libraries
should not be mixed. Refer to the "Mixing Shared and Archive Libraries"
section in the HP-UX Online Linker and Libraries User's Guide.
Specifying Other Libraries
You can specify other libraries using the -l option.
For example, in order to use the Tools.h++ library, specify -lrwtool:
aCC myapp.C -lrwtool
This section provides information about shared libraries that is specific to
HP aC++.
Select one of the following topics:
For More Information
By default, aC++ generates position independent code (PIC),
so no specific action is required. For more
information on Symbol Binding,
see -B
To create a shared library from one or more object files, use the
-b option at link time.
The -b option creates a shared
library rather than an executable file.
CAUTION:
You must use the aCC command to create a C++ shared library.
This is because the aCC command ensures that any static constructors and
destructors in the shared library are executed at the appropriate times.
Example
aCC -b -o util.so util.o
This example links util.o and creates the shared library util.so.
To use a shared library, you simply include the name of the library on the
aCC command line as you would with an archive library, or use the
-l option, as with other libraries.
The linker links the shared library to the
executable file it creates. Once you create an executable file that uses a
shared library, you must not move the shared library or the dynamic loader
(dld.so(5)) will not be able to find it.
CAUTION:
You must use the aCC command to link any program that uses a C++
shared library. This is because the aCC command
ensures that any static constructors and destructors in the shared library are
executed at the appropriate times.
Example
aCC prog.C util.so
This example compiles prog.C, links it with the shared library
util.so, and creates the executable file a.out.
The following command compiles the two files Strings.C and Arrays.C
and creates the two object files Strings.o and Arrays.o.
aCC -c Strings.C Arrays.C
The following command builds a shared library named libshape.so
from the object files Strings.o and Arrays.o:
aCC -b -o libshape.so Strings.o Arrays.o
The following command compiles a program, draw_shapes.C, that uses the
shared library, libshape.so:
aCC draw_shapes.C libshape.so
If both an archive and shared version of a particular library reside in
the same directory, the linker links in the shared version by default.
You can override this behavior with the -a linker option.
The -a linker option tells the linker which type of library to use.
The -a option is positional and applies to all subsequent libraries
specified with the -l option until the end of the
command line or until the next -a option is encountered.
Pass the -a option to the linker with the
-Wx,args option.
Syntax:
The syntax of the -a linker option when used with aCC is:
-Wl,-a,{archive
shared
default}
The different meanings of this option are:
-
-Wl,-a,archive
- Select archive libraries. If the archive library does not
exist, the linker generates a warning message and does not create the
output file.
-
-Wl,-a,shared
- Select shared libraries. If the shared library does not
exist, the linker generates a warning message and does not create the output
file.
-
-Wl,-a,default
- Select the shared library if it exists; otherwise, select
the archive library.
Example:
The following example directs the linker to use the
archive version of the library libshape, followed by standard shared
libraries if they exist; otherwise select archive versions.
aCC box.o sphere.o -Wl,-a,archive -lshape -Wl,-a,default
The aCC command cannot replace or delete object modules in a shared library.
To update a C++ shared library, you must recreate the library with
all the object files you want the library to include.
If, for example, a module in an existing shared library requires a fix, simply
recompile the fixed module then recreate the shared library with
the -b option. Any programs that use this library
will now be using the new versions of the routines. That is, you do not have
to relink any programs that use this shared library because they are attached
at run time.
This section explains additional things you can do with shared libraries. For
more information about Symbol Binding,
see -B
Select one of the following:
By default, the linker exports from a program only those symbols
that were imported by a shared library. For example, if an
executable's shared libraries do not reference the program's
main routine, the linker does not include the main symbol in
the a.out file's export list.
Normally, this is a problem only when a program explicitly calls shared
library management routines. (See Routines and Options to Manage C++ Shared Libraries.)
To make the linker export all symbols from a program, use the
-Wl,-E option which passes the -E option to
the linker.
Because shared library routines and data are not actually contained in the
a.out file, the dynamic loader must attach the routines
and data to the program at run time.
To accelerate program startup time, routines in a shared library are not bound
until referenced. (Data items are always bound at program startup.) This
deferred binding distributes the overhead of binding
across the total execution
time of the program and is especially helpful for programs that contain many
references that are not likely to be executed.
Forcing Immediate Binding
You can force immediate binding, which forces all routines and data to be
bound at startup time. With immediate binding, the overhead of binding
occurs only at program startup time, rather than across the program's
execution. Immediate binding also detects unresolved symbols at startup
time, rather than during program execution. Another use of immediate binding
is to provide better interactive performance, if you don't mind program
startup taking longer. To force immediate binding, use the option
-Wl,-B,immediate.
Example
The following example forces immediate binding:
aCC -Wl,-B,immediate draw_shapes.o -lshape
To specify default binding, use -Wl,B,deferred.
For More Information
For more information, see the HP-UX Online Linker and Libraries User's Guide.
Also see dlopen(3) and dlclose(3).
When you use a C++ shared library, all constructors and destructors of
nonlocal static objects in the library are executed. This differs from
a C++ archive library where only the constructors and destructors
that are actually used in the application are executed.
You can call any of several routines to explicitly load and unload shared
libraries, and to obtain information about shared libraries.
If an error occurs when calling shared library management
routines, the system error variable, errno, is set to an
appropriate error value. Constants are defined for these error
values in /usr/include/errno.h
(see errno(2)).
Thus, if a program checks for these values, it must include errno.h:
#include
Linker Options to Manage Shared Libraries
Linker options are available for specifying shared library binding time,
symbol export, and other shared library management features.
Note, you must use the
-Wx,args
compiler option to specify any linker option on the compiler command line.
For More Information
For More Information
For more information about version control in shared libraries,
refer to the HP-UX Online Linker and Libraries User's Guide.
Several libraries providing system services are included with
HP-UX. You can access HP-UX standard libraries by using
header files that declare interfaces to those libraries.
These library routines are documented in the HP-UX Reference Manual.
Location of Standard HP-UX Header Files
The standard HP-UX header files are located in /usr/include.
Using Header Files
To use a system library function, your HP aC++ source code must include
the preprocessor directive #include. For example,
#include <filename.h>
where filename.h is the name of the C++ header file for the library
function you want to use. By enclosing filename.h in angle brackets, the
HP aC++ compiler looks for that particular header file in a standard
location on the system. The compiler first looks for header
files in /opt/aCC/include; if none are found,
it then searches /usr/include.
You can use header file options
to modify the search path.
Example of Using a Standard Header File
If you want to use the getenv function that is in the standard
system libraries
(/usr/lib/libc.sl and /usr/lib/libc.a),
you should specify:
#include <stdlib.h>
because the external declaration of getenv is found in the header
file
/usr/include/stdlib.h.
-
/opt/aCC/bin/aCC -- driver
the only supported interface to HP aC++
and to the linker for HP aC++ object files
-
/opt/aCC/lbin/ctcom -- compiler
performs source compilation; preprocessing is
incorporated into the compiler
-
/opt/aCC/bin/c++filt -- name demangler
implements the name demangling algorithm which encodes
function name, class name, parameter number and name
-
/usr/ccs/bin/ld -- linker
links executables and builds shared libraries
Note that some of the following run-time libraries are
provided in both shared and archive versions.
Header files for these libraries are located at /opt/aCC/include*.
For ## substitute 32 or 64 as appropriate.
- Standard C++ Library
-
/usr/lib/hpux##/libstd.so -- shared version
-
/usr/lib/hpux##/libstd.a -- archive version
-
/usr/lib/hpux##/libstd_v2.so -- shared version -AA
-
/usr/lib/hpux##/libstd_v2.a -- archive version -AA
- Tools.h++ Foundation Class Library
-
/usr/lib/hpux##/librwtool.so -- 32 bit shared version
-
/usr/lib/hpux##/librwtool.a -- 32 bit archive version
- HP aC++ Run-time Support Library
-
/usr/lib/hpux##/libCsup.so -- shared version
-
/usr/lib/hpux##/libCsup.a -- archive version
- IOStream Library
-
/usr/lib/hpux##/libstream.so -- shared version
-
/usr/lib/hpux##/libstream.a -- archive version