HP C/aC++ for PA-RISC Software manual Advanced Shared Library Features, Updating a Shared Library

Page 182

Syntax

-Wl,-a,{archivesharedshared_archivearchive_shareddefault}

where,

 

-Wl,-a,archive

Selects archive libraries. If the archive library does not exist,

 

the linker generates a warning message and does not create the

 

output file.

-Wl,-a,archive_shared

If archive_shared is active, the archive form is preferred,

 

but the shared form is allowed.

-Wl,-a,shared

Selects shared libraries. If shared libraries do not exist, the

 

linker generates a warning message and does not create the

 

output file.

-Wl,-a,shared_archive

If shared_archive is active, the shared form is preferred, but

 

the archive form is allowed.

-Wl,-a,default

Selects the shared library. If the shared library does not exist,

 

the linker selects 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

Updating a Shared Library

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.

For example, when a module in an existing shared library requires a fix, recompile the fixed module with the +z or +Z option, and recreate the shared library with the -boption.

Programs that use this library will now use the new versions of the routines. You do not have to relink programs that use this shared library because they are attached at run time.

Advanced Shared Library Features

This section explains additional things you can perform with shared libraries. It discusses the following topics:

Forcing the Export of Symbols in main

Binding Times

Side Effects of C++ Shared Libraries

Routines and Options to Manage C++ Shared Libraries

Version Control for Shared Libraries

Adding New Versions to a Shared Library

Forcing the Export of Symbols in main

By default, the linker exports from a program only those symbols that were imported by a shared library. For example, if shared libraries of an executable does not reference the main routine of the program, the linker does not include the main symbol in the export list of a.out.

Normally, this is a problem only when a program explicitly calls shared library management routines. (See “Routines and Options to Manage C++ Shared Libraries” (page 183).)

To make the linker export all symbols from a program, use the -Wl,-Eoption, which passes the -Eoption to the linker.

182 Tools and Libraries

Image 182
Contents HP aC++/HP C A.06.28 Programmers Guide Page Contents +FP Contents Contents Contents Copyright Notice and Identification Pragmas Pragma Directives and AttributesInitialization and Termination Pragmas Data Alignment PragmasContents Preprocessing Directives 119 Using HP aC++ Templates 132 Standardizing Your Code 138Optimizing HP aC++ Programs 156 Exception Handling 161Tools and Libraries 175 170Mixing C++ with Other Languages 188 Strings 194 Arrays Files in Fortran Distributing Your C++ Products 195Migrating from HP C++ cfront to HP aC++ 198 Documentation feedback 221 Diagnostic Messages 222 Glossary 223 Index 227HP secure development lifecycle What’s in This Document About This DocumentIntended Audience Typographical Conventions This document uses the following conventionsHP-UX Release Name and Release Identifier Publishing HistoryRelated Documents HP-UX 11i ReleasesHP Encourages Your Comments Following is a list of documents available with this releaseC89 C99 ecom Ctcom Getting Started with HP aC++Components of the Compilation System Other HP aC++ executable files areExecuting the Program Using the aCC CommandCompiling a Simple Program Debugging ProgramsCompiler Command Syntax and Environmental Variables Examples of the aCC Command++ Source File .C file Files on the aCC Command LineAssembly Language Source Files .s Files Preprocessed Source Files .i FilesObject Files .o Files Configuration Files .conf FilesEnvironment Variables Library Files .a and .so FilesCxxopts Environment Variable ACCFULLPATHNAMES Environment VariableACCMAXERR Environment Variable Cclibdir Environment VariableCcrootdir Environment Variable ACC -L/mnt/proj/lib file.o ACC file.oTmpdir Environment Variable Floating InstallationCxxmapfile Environment Variable Export CCROOTDIR=/mnt/CXX2.1Setting up Floating Installation HP aC++Command-Line Options ACC +DO11.22 +O3 app.C Options to Control Code GenerationACC -c sub.C prog.C ILP32 Data Model and LP64 Data ModelUsing +DS to Specify Instruction Scheduling Compiling in Networked EnvironmentsSize and Alignment of HP Compiler Data Types Data Alignment and StorageACC -S prog.C +expandtypesindiag Debugging OptionsFshort-enums ACC +u1 app.CG1 Algorithm When to use -g, -g0, and -g1Differences Between -g, -g0, and -g1 Options +macrodebug+pathtrace=kind +noobjdebug+pathtrace Local+pathtrace=globallocal Error HandlingNone ACC +p file.C+Wcontextlimit +wn+Wargs +Weargs +wperfadvice+We +Wv+wsecurity Exception HandlingExtensions to the Language +noeh+Onocxlimitedrange +OnofenvaccessFloating-Point Processing Options Nofpwidetypes FpevalFpevaldec +decfp+Oprefetchlatency +FPmode+Onolibmerrno +OnopreservedfpregsHeader File Options ACC -I include file.C Idirs -I- -Idirs Online Help Option +helpInlining Options +inlinelevel numExec Library OptionsDynamic Lname+nostl Linker OptionsMinshared +Onolibcalls=+Onodynopt UsymbolUsymbol +Onodynopt+ild Options for Naming the Output FileNative Language Support Option +ildrelinkBasic Optimization Level Options Handling Null Pointers OptionsCode Optimizing Options ACC -z file.C+O2 +O0+O1 +O3ACC +O3 prog.C Additional Optimization Options for Finer Control+O4 +O4+Onofailsafe Ipo+nonrv +Onolimit Advanced +Ooptimization Options+Onoaggressive +Onoptrstoglobals=list+Onodataprefetch +Onocrossregionaddressing+Onodatalayout +Onofltacc+Ofrequentlycalled +Onoinitcheck+Ointegeroverflow +Onoinline+Olit +Onoloopunroll +Olevel+Onolooptransform +Onoopenmp+Onoparmsoverlap +opts+Onoparminit +Onoprocelim+Oshortdata +Orarelycalled+Onosignedpointers +Onostoreordering +OtypesafetyProfile-Based Optimization Options +OunrollfactorDisplaying Optimization Information Parallel Processing OptionsInformation Embedding Options Annotate=structsOption Matrix for -mt Required if -DPOSIXCSOURCEis used+Onoautopar +tls=staticdynamicFast Performance Options+wlock +Ofast+nosrcpos +Ofaster+Onotlscallschangetp +DSmodel+ub Porting Options+sb +uc+wendian +w64bit+wdriver This warning can be suppressed by adding an extra castRedirecting Output From This Option Preprocessor OptionsDname +maked Maked+Maked Examples+profilebucketsize Profiling Code OptionsUname +check=all Runtime Checking Options+check +check=none+check=boundsarray +check=boundspointer Compiling with +check=boundspointerCheck off by one out-of-bounds access Check off by any number out-of-bounds access+check=globals +check=lock+check=malloc +check=stackframevariablesnone +check=threadCh = intval & 0xff +check=truncateexplicit +check=truncateexplicitimplicit+check=uninit +check=truncateimplicitAarm Standards Related OptionsAarm Ag++ AC89AC99 Agcc+legacyv5 AOa and -AOe+legacycpp +std=c89c99c++98c++11gccg++gnu +stl=rwnoneWc,-koeniglookup,onoff +tru64Wc,-ansiforscope,onoff +tru64More Examples of -t Subprocesses of the CompilerTx,name Tx,nameWx,args Bextern Symbol Binding OptionsBdefault Passing Options to the Linker with -WBprotected BhiddenBhiddendef BprotecteddataTemplate Options Trigraph Processing Suppression Option +instincludesuffixesVerbose Compile and Link Information Process Compiler 94/u 65/s 35/r 37/u 76/s 02/r ACC myfile.C -v -g1 ACC myfile.C -vg1 ACC -vg1 myfile.C Concatenating OptionsACC -V app.C Pragma Directives and Attributes Initialization and Termination PragmasCopyright Notice and Identification Pragmas #pragma Versionid Software Product, Version 12345.A.01.05 Data Alignment Pragmas#pragma Versionid string #pragma align NData Alignment Pragmas Basic Example Template ExampleImplicit Access to Unaligned Data Handling Unaligned Data#pragma unalign Typedef T1 T2 Interaction between pack and unalign pragmas is as followsOptimize Pragma Optimization PragmasOptlevel Pragma Floattrapson PragmaNoinline Pragma Diagnostic Pragmas Other PragmasEstimatedfrequency Pragma Defaultbinding PragmaBinding Pragma Extern PragmaHpdefinedexternal Pragma Hdrstop PragmaHidden Pragma Hpdefinedinternal PragmaProtected Pragma POP PragmaPragma once Ptrsstronglytyped PragmaStdc FLOATCONSTDECIMAL64 Pragma #pragma Stdc FLOATCONSTDECIMAL64 on OFF DefaultStdc Cxlimitedrange Pragma Stdc Fpcontract PragmaOMP Atomic Pragma Stdc Fenvaccess PragmaUnrollfactor Pragma OMP for Pragma OMP Barrier PragmaOMP Critical Pragma OMP Flush PragmaOMP Parallel Pragma OMP Master PragmaOMP Ordered Pragma OMP Parallel for PragmaOMP Single Pragma OMP Parallel Sections PragmaOMP Sections Pragma OMP Task PragmaOpenMP Clauses Shared DefaultCopyprivate CopyinAttributes Attribute nonexposing Attribute nonexposingAttribute noreturn Attribute noreturnAttribute warnunusedresult Attribute formatAttribute visibility Syntax Preprocessing DirectivesOverview of the Preprocessor Usage GuidelinesDescription Source File Inclusion #include, #includenextSyntax Assertions #assert, #unassertExamples Macro Replacement #define, #undef#define mac very very long\ Replacement string Macros with ParametersExample Specifying String Literals with the # OperatorConcatenating Tokens with the ## Operator Following illustrates the ## operatorVar1 is Using Macros to Define ConstantsOther Macros #define Arraysize 1000float xARRAYSIZEUsing Constants and Inline Functions Instead of Macros Assertions #assert, #unassert Predefined MacrosCode that compiles if the expression evaluates to zero Conditional Compilation #if, #ifdef, .. #endifHP aC++ predefines the following predicates Using the #ifdef and #ifndef Directives Using the defined OperatorUsing the #if Directive Using the #else Directive#line 5 myfile Line Control #lineExample Pragma Directive #pragma and Pragma Operator This macro enables the following non-standard featuresIostream Performance Improvement Pragma See page 96 for more information on pragmasExamples Error Directive #errorTrigraph Sequences Line below contains the trigraph sequence ??=When this line is compiled it becomes ??=line 5 myfileScope and Precedence Using HP aC++ TemplatesInvoking Compile-Time Instantiation Template ProcessingPerformance Explicit InstantiationUsage Template class TablecharFunction Template Command-Line Option InstantiationCompile-Time Instantiation ACC -c +instcompiletime a.C ACC -c a.CPossible Duplicate Symbols in Archive Libraries Why Use Compile-Time InstantiationPossible Duplicate Symbols in Shared Libraries ScopeBuilding an Archive Library with +instauto/+instclose ++ Template TutorialClass Templates Building an Archive Library with Compile-time InstantiationFunction Templates Bool Keyword Standardizing Your CodeHP aC++ Keywords HP aC++ KeywordsCompile time error message is Dynamiccast KeywordAbove generates a compile-time error Explicit Keyword Classic example of this problem is an array class Mutable Keyword Namespace and using Keywords Connections Across Translation UnitsAn Auxiliary Translation Unit Using- declarations and using- directivesUsing Nx // Where N is a namespace, x is a name in N IntPage Class Base Virtual void f Must have a virtual function to Volatile Keyword Typename Keyword Wchart KeywordTemplate Keyword Declare a class as a member of the class template C2 below Overloading new and delete for ArraysUse it as the name of the template C below Example Invalidargument RangeerrorStandard Exception Classes Following exceptions are thrown by the Standard C++ Library Exceptions Thrown by the Standard C++ LibraryTypeinfo Class Unsupported Functionality Int before const typeinfo& constMemfun1reft Memfunreft Iostream Requesting Optimization Setting Basic Optimization LevelsOptimizing HP aC++ Programs Level 1 OptimizationLevel 4 Optimization Additional Options for Finer ControlLevel 3 Optimization Enabling Aggressive OptimizationsEnabling Only Conservative Optimizations Removing Compilation Time Limits When OptimizingProfile-Based Optimization Limiting the Size of Optimized CodeMaintaining Profile Data Files InstrumentationCollecting Data for Profiling Sample.exe input.file1 Sample.exe input.file2ACC -o sample.exe +Oprofile=use +O3 sample.C Pragmas That Control OptimizationPerforming Profile-Based Optimization See Optimization Pragmas page 103 for more informationException Handling Exception Handling in C++Basic Exception Handling Example Function Try Block ExamplesDebugging Exception Handling Performance Considerations Using ThreadsUsing Locks Rogue Wave Standard C++ LibraryRogue Wave Standard C++ Library 1.2.1 and Tools.h++ Required Command-line OptionsRogue Wave Standard C++ Library LpthreadThis option applies only to kernel threadsLimitations Using -DTHREADSAFE with the cfront Compatible libstreamUsing -DHPACCTHREADSAFERBTREE Cout endlACC -mt prog.c Pthreads Posix ThreadsException Handling OpenMP Implementation Parallel Programming Using OpenMPFunction Scoping OpenMP APIs are defined in the library libomp OpenMP Header FileOpenMP Library Openmp Macro +Onoopenmp Command Line OptionEnvironment Variables in OpenMP Where, kind is either of of static, dynamic, or guidedExport OMPDYNAMIC=value Setenv Ompdynamic value Runtime Library Functions in OpenMPExecution Environment Functions Export OMPNESTED=value Setenv Ompnested valueOmpgetmaxthreads OmpsetnumthreadsOmpgetnumthreads OmpgetthreadnumOmpgetdynamic Lock FunctionsOmpsetdynamic OmpsetnestedOmpsetlock and ompsetnestlock Ompinitlock and ompinitnestlockOmpdestroylock and ompdestroynestlock Ompunsetlock and ompunsetnestlockOmpgetwtime Timing FunctionsOmptestlock and omptestnestlock Functions OmpgetwtickTools and Libraries HP Specific Features of lex and yaccCreating and Using Libraries Locale directive for lexStandard C++ Library Introduction to Using the Standard C++ LibraryHP aC++ Libraries IntroductionDifferences between Standard C++ Library and Other Libraries Non-Object-Oriented Design of the Standard C++ LibraryStandard C++ Library Reference Incompatibilities Between the Library and the StandardHP aC++ Runtime Support Library ACC -DHPACCUSINGMULTIPLIESINFUNCTIONAL test.cTools.h++ Library IOStream LibraryLinking with Shared or Archive Libraries Creating and Using Shared LibrariesLinking to C++ Libraries Specifying Other LibrariesCreating a Shared Library Using a Shared LibraryExample of Creating and Using a Shared Library Linking Archive or Shared LibrariesUpdating a Shared Library Advanced Shared Library FeaturesForcing the Export of Symbols in main Routines and Options to Manage C++ Shared Libraries Binding TimesSide Effects of C++ Shared Libraries Linker Options to Manage Shared LibrariesStandard HP-UX Libraries and Header Files Allocation Policies for ContainersFor -AA Standard Library For a string typeHP aC++ File Locations HP aC++ Executable FilesUsr/lib/hpux##/libCsup11.so ISO C++11 standard compliant HP aC++ Runtime Libraries and Header FilesUsr/lib/hpux##/libCsup.so Data Compatibility between C and C++ Mixing C++ with Other LanguagesCalling Other Languages Syntax of extern C Using the extern C Linkage SpecificationHP aC++ Calling HP C Examples of extern CExamples HP aC++ Calling HP C Differences in Argument Passing ConventionsMain Function Enter the nameJoann Joann has a balance HP C Calling HP aC++Running the Example To compile the example, run the following commands Compiling and Running the Sample ProgramsFunction Naming Conventions Using Reference Variables to Pass ArgumentsCalling HP Fortran 90 from HP aC++ Example of Reference Variables as ArgumentsArrays Using extern C LinkageStrings Files in FortranDistributing Your C++ Products Applications that use HP aC++ Shared LibrariesHP aC++ Files You May Distribute Installing your ApplicationLinking Your HP aC++ Libraries with Other Languages Terms for Distribution of HP aC++ Files Getting Started with Migration Migrating from HP C++ cfront to HP aC++General Guidelines for Migration CC +p cfrontfile.CWriting Code for both Compilers Command-Line DifferencesNew Command-Line Options Explicit Loading and Unloading of Shared LibrariesObsolete Command-Line Options Describes obsolete command-line options for HP aC++Changed Command-Line Options PtvException Handling is the Default Migration Considerations when DebuggingMigration Considerations when Using Exception Handling See Debugging Options page 35 for complete informationPossible Differences when Exiting a Signal Handler Memory Allocation Failure and operator newDifferences in setjmp/longjmp Behavior Calling unexpectedUnreachable catch Clauses Throwing an Object having an Ambiguous Base ClassMigration Considerations when Using Libraries Standards Based LibrariesManip3C++ iostream manipulators HP C++ cfront Compatibility LibrariesFstream3C++ iostream and streambuf specialized to files Man 3s filebufHP C++ cfront Task Library Not Supported Migration Considerations Related to PreprocessingHP C++ cfront Complex Library Not Supported Replace #include with complexChanges in C++ Semantics Migration Considerations Related to StandardizationObsolete Preprocessor Options Implicit Typing of Character String LiteralsOverload Resolution Ambiguity of Subscripting Operator Execution Order of Static Constructors in Shared LibrariesExplicit int Declaration Changes in C++ SyntaxMore Frequent Inlining of Inline Code Equivalent, valid HP aC++ code follows For Statement, New Scoping RulesStruct as Template Type Parameter is Permitted WC,-ansiforscope,onTokens after #endif This code compiles without error with HP aC++Base Template Class Reference Syntax Change Overload not a KeywordDeclaring friend Classes Dangling Comma in enumStatic Member Definition Required Duplicate Formal Argument Names Using in Class DefinitionsIncorrect Syntax for Calls to operator new Ambiguous Function or Object DeclarationOverloaded Operations ++ Reference InitializationCompiling this code HP aC++ generates the following error Using operator new to Allocate ArraysOn HP aC++, the following error is generated Parentheses in Static Member Initialization ListQualified-id Required in Static Member Initialization List Non-constant Reference InitializationDigraph White Space Separators Migration Considerations when Using TemplatesVerbose Template Processing Information CA aCfront Implicit Include Convention Converting Directed Mode to Explicit InstantiationCommon Template Migration Syntax Changes Documentation feedback Frequently Encountered Messages Diagnostic MessagesAC++ Message Catalog Glossary AggressiveInternational Standard defines only synchronous exceptions See template Glossary Symbols IndexCrootdir FLOATTRAPSON, 103 FREQUENTLYCALLED, 106 HDRSTOP, 107 Hidden Index
Related manuals
Manual 15 pages 49.53 Kb