Developing and Porting C and C++ Applications on AIX
Total Page:16
File Type:pdf, Size:1020Kb
IBM Front cover Developing and Porting C and C++ Applications on AIX Detailed explanations about 32- and 64-bit process models Effective management of shared objects and libraries Exploring parallel programming using OpenMP Keigo Matsubara Edison Kwok Inge Rodriguez Murali Paramasivam ibm.com/redbooks International Technical Support Organization Developing and Porting C and C++ Applications on AIX June 2003 SG24-5674-01 Note: Before using this information and the product it supports, read the information in “Notices” on page xvii. Second Edition (June 2003) This edition applies to C for AIX (program number 5765-F57) and VisualAge C++ for AIX Version 6.0 (product number 5765-F56) installed on AIX 5L Version 5.2 (product number 5765-E62). © Copyright International Business Machines Corporation 2000, 2003. All rights reserved. Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Figures . xiii Tables . xv Notices . xvii Trademarks . xviii Preface . xix The team that wrote this redbook. xix Become a published author . xx Comments welcome. xxi Summary of changes . xxiii June 2003, Second Edition . xxiii September 2000, First Edition . xxiv Chapter 1. C and C++ compilers . 1 1.1 C for AIX Version 6.0. 2 1.1.1 New or improved optimization features. 2 1.1.2 ISO C Standard conformance . 4 1.1.3 GNU C compatibility . 10 1.1.4 Enhanced language level support. 15 1.2 VisualAge C++ for AIX Version 6.0 . 16 1.2.1 New or improved optimization features. 16 1.2.2 OpenMP support . 17 1.2.3 Automatic parallelization . 18 1.2.4 Improved template handling . 18 1.2.5 C99 features . 18 1.2.6 GNU G++ compatibility . 18 1.3 Installing the compilers . 19 1.3.1 Install compiler filesets . 19 1.3.2 Retaining a previous version of the compiler . 22 1.4 Activating the compilers . 23 1.4.1 What is LUM . 23 1.4.2 Configuring LUM . 23 1.5 Activating the LUM server . 26 1.6 Enrolling a product license . 27 1.6.1 Enrolling a concurrent license . 28 1.6.2 Enrolling a simple nodelock license . 29 © Copyright IBM Corp. 2000, 2003. All rights reserved. iii 1.7 Invoking the compilers. 29 1.7.1 Default compiler drivers . 30 1.8 Where to find help . 31 1.8.1 Online documentations . 31 1.8.2 Viewing online documentation remotely . 31 1.8.3 Where to find help on the Web . 34 1.8.4 Applying fixes and service updates. 35 Chapter 2. Compiling and linking . 37 2.1 32- and 64-bit development environments . 38 2.1.1 The 64-bit advantage . 39 2.1.2 Compiler support. 40 2.1.3 Utility commands support . 42 2.2 Compiling and linking: A quick overview . 43 2.2.1 Building C and C++ programs with system libraries . 43 2.2.2 Objects and libraries . 45 2.2.3 Difference between shared object and library on AIX . 49 2.2.4 Difference between shared and static objects on AIX. 51 2.3 Resolving symbols at link-time . 53 2.3.1 The -L linker option . 55 2.3.2 Searching objects and libraries at link-time. 56 2.3.3 LIBPATH environment variable. 58 2.3.4 Link-time and load-time. 61 2.4 Supported link methods on AIX. 63 2.4.1 AIX default linking . 64 2.4.2 Static linking . 66 2.4.3 Lazy loading . 67 2.5 Run-time linking. 68 2.5.1 How to use run-time linking. 70 2.5.2 Examining the executable and shared objects using dump . 75 2.5.3 Enabling the main program object as run-time linking . 78 2.5.4 Rebinding symbols at the program load-time . 79 2.5.5 Extended search order with the -brtl linker option. 81 2.6 Dynamic loading . 82 2.7 Commands when manipulating objects and libraries . 85 2.7.1 dump . 86 2.7.2 genkld . 88 2.7.3 ldd . 90 2.7.4 nm . 90 2.7.5 rtl_enable . 91 2.7.6 slibclean . 91 2.8 Creating shared objects . 92 2.8.1 Import and export files. 92 iv Developing and Porting C and C++ Applications on AIX 2.8.2 A self-contained shared object . 95 2.8.3 Interdependent shared objects . 96 2.8.4 Initialization and termination routines . 99 2.9 Shared libraries in a development environment . 99 2.9.1 Production and development environments . 100 2.9.2 Private shared objects. 101 2.9.3 NFS consideration. 102 2.9.4 Sufficient free disk space on the target directory and /tmp . 102 Chapter 3. Understanding user process models . 105 3.1 User process models on AIX. 106 3.1.1 How to determine hardware bit mode . 107 3.1.2 How to determine kernel bit mode . 107 3.1.3 How to determine user process bit mode . ..