Linking shared libraries

This topic discusses symbol exports, symbol visibility, and how to link shared libraries.

Starting from IBM® Open XL C/C++ for AIX® 17.1.0, the -shared option is functionally equivalent to the classic -qmkshrobj option that is shipped in IBM XL C/C++ for AIX 16.1.0 and earlier releases. If you specify the -shared option on the link step, the compiler instructs the linker to generate a single shared library file rather than an executable for all input files. The default name of the output file is a.out. To rename the output file , use the -o file_name option. Additionally, the -bcdtors::priority: option is functionally equivalent to makeC++SharedLib -p priority or -qmkshrobj=priority, both of which are shipped in IBM XL C/C++ for AIX 16.1.0 and earlier releases. With the -bcdtors::priority: option, you can specify the priority level for the initialization order of static C++ objects declared in a shared object.

Starting from IBM Open XL C/C++ for AIX 17.1.0, the equivalent of the classic option -qtwolink is -bcdtors:csect. However, with -bcdtors:csect, code generated with IBM Open XL C/C++ for AIX 17.1.3 might not work correctly with the linker because necessary symbols might be discarded. If you used -qtwolink in IBM XL C/C++ for AIX 16.1.0 or earlier releases to minimize the number of constructors that are included from libraries and object files, you are recommended to use -bcdtors:mbr instead in IBM Open XL C/C++ for AIX 17.1.3. With the -bcdtors:mbr option, the linker discard libraries that include startup initialization but are unreferenced. Refer to ld Command in the AIX documentation for more details.